-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jukebox.ino
163 lines (157 loc) · 7.1 KB
/
jukebox.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#include "pitches.h"
int melody1[] = {NOTE_C5, NOTE_F5, NOTE_C5, NOTE_F4, NOTE_A4, NOTE_C5, NOTE_F5, NOTE_C5,
NOTE_C5, NOTE_F5, NOTE_C5, NOTE_F5,
NOTE_A5, NOTE_G5, NOTE_F5, NOTE_E5, NOTE_D5, NOTE_CS5,
NOTE_C5, NOTE_F5, NOTE_C5, NOTE_F4, NOTE_A4, NOTE_C5, NOTE_F5, NOTE_C5,
NOTE_F5, NOTE_D5, NOTE_C5, NOTE_AS4,
NOTE_A4, NOTE_G4, NOTE_F4, NOTE_C5, NOTE_F5, NOTE_C5, NOTE_F4, NOTE_A4, NOTE_C5, NOTE_F5, NOTE_C5,
NOTE_C5, NOTE_F5, NOTE_C5, NOTE_F5,
NOTE_A5, NOTE_G5, NOTE_F5, NOTE_E5, NOTE_D5, NOTE_CS5,
NOTE_C5, NOTE_F5, NOTE_C5, NOTE_F4, NOTE_A4, NOTE_C5, NOTE_F5, NOTE_C5,
NOTE_F5, NOTE_D5, NOTE_C5, NOTE_AS4,
NOTE_A4, NOTE_G4, NOTE_F4,
};
int noteDuration1[] = { 4, 4, 4, 8, 8, 4, 4, 2,
4, 4, 4, 4,
3, 8, 8, 8, 8, 8,
4, 4, 4, 8, 8, 4, 4, 2,
3, 8, 4, 4,
4, 4, 2 , 4, 4, 4, 8, 8, 4, 4, 2,
4, 4, 4, 4,
3, 8, 8, 8, 8, 8,
4, 4, 4, 8, 8, 4, 4, 2,
3, 8, 4, 4,
4, 4, 2
};
int melody2[] = {NOTE_G4, NOTE_G4, NOTE_G4, NOTE_G4, NOTE_G4, NOTE_G4, NOTE_G4, NOTE_G4, NOTE_G4,
NOTE_B3, NOTE_G3, NOTE_C4, NOTE_G3, NOTE_CS4, NOTE_G3, NOTE_C4, NOTE_G3, NOTE_B3, NOTE_G3, NOTE_C4, NOTE_G3, NOTE_CS4, NOTE_G3, NOTE_C4, NOTE_G3,
NOTE_E4, NOTE_F4, NOTE_F4, NOTE_F4, NOTE_F4, NOTE_E4, NOTE_E4, NOTE_E4,
NOTE_E4, NOTE_G4, NOTE_G4, NOTE_G4, NOTE_G4, NOTE_E4, NOTE_E4, NOTE_E4, NOTE_E4, NOTE_F4, NOTE_F4, NOTE_F4, NOTE_F4, NOTE_E4, NOTE_E4, NOTE_E4,
NOTE_E4, NOTE_G4, NOTE_G4, NOTE_G4, NOTE_G4, NOTE_E4, NOTE_E4, NOTE_E4,
NOTE_E4, NOTE_F4, NOTE_F4, NOTE_F4, NOTE_F4, NOTE_E4, NOTE_E4, NOTE_E4,
NOTE_E4, NOTE_G4, NOTE_G4, NOTE_G4, NOTE_G4, NOTE_E4, NOTE_E4, NOTE_E4,
NOTE_DS5, NOTE_D5, NOTE_B4, NOTE_A4, NOTE_B4,
NOTE_E4, NOTE_G4, NOTE_DS5, NOTE_D5, NOTE_G4, NOTE_B4,
NOTE_B4, NOTE_FS5, NOTE_F5, NOTE_B4, NOTE_D5, NOTE_AS5,
NOTE_A5, NOTE_F5, NOTE_A5, NOTE_DS6, NOTE_D6
};
int noteDuration2[] = {8, 8, 2, 8, 8, 2, 16, 8, 16, 8, 8,
2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4,
8, 16,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S4,
NOTE_DS4, NOTE_GS3,
NOTE_G3, NOTE_CS4,
NOTE_C4, NOTE_FS4, NOTE_F4, NOTE_E3, NOTE_AS4, NOTE_A4,
NOTE_GS4, NOTE_DS4, NOTE_B3,
NOTE_AS3, NOTE_A3, NOTE_GS3,
0, 0, 0};
int noteDuration3[] = { 12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
9, 9, 9,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
9, 9, 9,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 12, 12,
12, 12, 6,
3,
12, 12, 12, 12,
12, 12, 6,
3,
12, 12, 12, 12, 12, 12, 6, 3, 12, 12, 12, 12, 12, 12, 6, 6, 18, 18, 18, 6, 6, 6, 6, 6, 6, 18, 18, 18, 18, 18, 18, 10, 10, 10, 10, 10, 10, 3, 3, 3};
byte button1 = 1; // or whatever pins are being used
byte button2 = 2;
byte button3 = 3;
void setup() {
pinMode (button1, INPUT_PULLUP); // button with internal pullup, switch presses connects to Gnd
pinMode (button2, INPUT_PULLUP);
pinMode (button3, INPUT_PULLUP);
}
void loop(){
if (digitalRead(button1) == LOW)
for (int thisNote = 0; thisNote < 100; thisNote++) {
int noteDuration = 1000 / noteDuration1[thisNote];
tone(13, melody1[thisNote], noteDuration);
int pauseBetweenNotes = noteDuration * 1.40;
delay(pauseBetweenNotes);
noTone(13);
}
if (digitalRead(button2) == LOW)
for (int thisNote = 2; thisNote < 110; thisNote++) {
int noteDuration = 1000 / noteDuration2[thisNote];
tone(13, melody2[thisNote], noteDuration);
int pauseBetweenNotes = noteDuration * 1.10;
delay(pauseBetweenNotes);
noTone(13);
}
if (digitalRead(button3) == LOW)
for (int thisNote = 3; thisNote < 150; thisNote++) {
int noteDuration = 1000 / noteDuration3[thisNote];
tone(13, melody3[thisNote], noteDuration);
int pauseBetweenNotes = noteDuration * 1.40;
delay(pauseBetweenNotes);
noTone(13);
}
}