From bbba1d1563b93006b45fb47427a0a4737f6511a8 Mon Sep 17 00:00:00 2001 From: dakkar Date: Fri, 21 Aug 2020 16:18:08 +0100 Subject: actual notes --- esp32/lego-piano.ino | 43 +++++++++++++++++++++++++++++++------------ 1 file 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 -- cgit v1.2.3