Update README.md
[miniband.git] / arduino / guitar.ino
1
2 #define THRESHOLD 16
3 #define PADNUM 1
4 #define PINLIMIT 5000
5
6 int val;
7 int pinDelay;
8 int pinDelays[4] = { 0, 0, 0, 0 };
9
10 void setup() {
11 Serial.begin(57600);
12 }
13
14 void loop() {
15 for(int i = 0; i < PADNUM; i++) {
16 val = analogRead(i);
17 pinDelay = pinDelays[i];
18
19 if (val >= THRESHOLD && pinDelay < 1) {
20 Serial.print(i);
21 Serial.print(",");
22 Serial.print(val);
23 Serial.println();
24 pinDelays[i] = PINLIMIT;
25 }
26
27 if (pinDelay > 0) {
28 pinDelays[i] = pinDelay - 1;
29 }
30 }
31 }
32