aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2020-08-21 16:18:08 +0100
committerdakkar <dakkar@thenautilus.net>2020-08-21 16:18:08 +0100
commitbbba1d1563b93006b45fb47427a0a4737f6511a8 (patch)
tree23d2fbaaa377fe39b93231514204f918fa2e2f38
parentusing arduino-esp32 branch esp32s, it plays! (diff)
downloadlego-piano-bbba1d1563b93006b45fb47427a0a4737f6511a8.tar.gz
lego-piano-bbba1d1563b93006b45fb47427a0a4737f6511a8.tar.bz2
lego-piano-bbba1d1563b93006b45fb47427a0a4737f6511a8.zip
actual notes
-rw-r--r--esp32/lego-piano.ino43
1 files changed, 31 insertions, 12 deletions
diff --git a/esp32/lego-piano.ino b/esp32/lego-piano.ino
index 42c7e1a..2dfa916 100644
--- a/esp32/lego-piano.ino
+++ b/esp32/lego-piano.ino
@@ -108,9 +108,35 @@ int sense(int led) {
return value < 500;
}
-int count=0;
-uint32_t notes[] = { 440, 880, 1200 };
-int currentNote = 0;
+uint32_t notes[] = {
+ 261, // C4
+ 277,
+ 294, // D4
+ 311,
+ 330, // E4
+ 349, // F4
+ 370,
+ 392, // G4
+ 415,
+ 440, // A4
+ 466,
+ 494, // B4
+
+ 523, // C5
+ 554,
+ 587, // D5
+ 622,
+ 659, // E5
+ 698, // F5
+ 740,
+ 783, // G5
+ 831,
+ 880, // A5
+ 932,
+ 988, // B5
+
+ 1046, // C6
+};
void loop() {
/* Serial.print("current led "); */
@@ -123,20 +149,13 @@ void loop() {
lastSeen = currentLed;
Serial.print(currentLed);
Serial.println(" proximity!");
+ play(notes[currentLed]);
}
}
else if (lastSeen == currentLed) {
lastSeen = 100;
+ mute();
}
currentLed = (currentLed+1)%25;
-
- if (count == 450) {
- //mute();
- }
- else if (count == 0) {
- play(notes[currentNote]);
- currentNote = (currentNote+1)%3;
- }
- count = (count+1)%500;
} \ No newline at end of file