analog_001.ino (564B)
1 int knobs[6], oldknobs[6]; 2 int pins[6] = {A0, A1, A2, A3, A4, A5}; 3 4 void 5 setknobs(void) { 6 int i; 7 for (i = 0; i < 6; i++) 8 knobs[i] = analogRead(pins[i])>>3; 9 } 10 11 void 12 setoldknobs(void) { 13 int i; 14 for (i = 0; i < 6; i++) oldknobs[i] = knobs[i]; 15 } 16 17 void setup() { 18 setknobs(); 19 Serial.begin(115200); 20 } 21 22 void loop() { 23 int i; 24 char msg[3]; 25 char buf[1024]; 26 setoldknobs(); 27 setknobs(); 28 for (i = 0; i < 6; i++) { 29 if (oldknobs[i] != knobs[i]) { 30 msg[0] = 0xB0; 31 msg[1] = i; 32 msg[2] = knobs[i]; 33 Serial.write(msg, 3); 34 } 35 } 36 }