7781cabd1779e12f89b7349c5d86bc7daca1e792
[miniband.git] / release / drums / drums.ino
1
2 const int NUMBER_OF_DRUMS = 4;
3 const int DELAY = 500;
4
5 const int PINS[4] = { 8, 9, 10, 11 };
6 int pinDelays[4] = { 0, 0, 0, 0 };
7
8 void setup() {
9 for (int i = 0; i < NUMBER_OF_DRUMS; i++) {
10 pinMode(PINS[i], INPUT);
11 }
12 Serial.begin(9600);
13 }
14
15 void loop() {
16 for (int i = 0; i < NUMBER_OF_DRUMS; i++) {
17 if (digitalRead(PINS[i]) == HIGH && pinDelays[i] < 1) {
18 Serial.print("drum,");
19 Serial.println(i);
20 pinDelays[i] = DELAY;
21 }
22 if (pinDelays[i] > 0) {
23 pinDelays[i] -= 1;
24 }
25 }
26 }
27