-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPiano.ino
77 lines (71 loc) · 1.76 KB
/
Piano.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
int i;
const int n = 26;
int buttonPushCounter=0;
int buttonState[n];
int lastButtonState[n];
int buttonPushCounter2 = 0;
int buttonState2 = 0;
int lastButtonState2 = 0;
int buttonPushCounter3 = 0;
int buttonState3 = 0;
int lastButtonState3 = 0;
int buttonPushCounter4 = 0;
int buttonState4 = 0;
int lastButtonState4 = 0;
void setup ()
{
Serial.begin (115200);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
pinMode(12, INPUT_PULLUP);
pinMode(13, INPUT_PULLUP);
pinMode(14, INPUT_PULLUP);
pinMode(15, INPUT_PULLUP);
pinMode(16, INPUT_PULLUP);
pinMode(17, INPUT_PULLUP);
pinMode(18, INPUT_PULLUP);
pinMode(19, INPUT_PULLUP);
pinMode(20, INPUT_PULLUP);
pinMode(21, INPUT_PULLUP);
pinMode(22, INPUT_PULLUP);
pinMode(23, INPUT_PULLUP);
pinMode(24, INPUT_PULLUP);
pinMode(25, INPUT_PULLUP);
pinMode(26, INPUT_PULLUP);
}
void loop()
{
for (i=0;i<n;i++){
buttonState[i] = digitalRead(i+2);
if (buttonState[i] != lastButtonState[i]) {
if (buttonState[i] == LOW) {
buttonPushCounter++;
Serial.write (144);
Serial.write (60+i);
Serial.write (100);
}
else {
Serial.write (144);
Serial.write (60+i);
Serial.write (0);
delay(50);
}
}
lastButtonState[i] = buttonState[i];
/*
if (buttonPushCounter % i == 0) {
digitalWrite(i, HIGH);
}
else {
digitalWrite(i, LOW);
}*/
}
}