- How to achieve doing multiple things at once - counting down and displaying the countdown timer AND simultaneously playing the jingle in correct time - without the use of delay()
- How to program your own selection of jingles very easily using a flexible programming syntax to transcribe music notation into something that the Arduino can play keeping perfect time
We first start with horizontally stacking ProtoStax Enclosure for Arduino and ProtoStax Enclosure for Breadboard in a "Platform Configuration" - i.e with just the bottom plates - to have an open prototyping platform consisting of the Arduino and Breadboard. This facilitates doing all the wiring, trying everything out, and programming the Arduino while having full and open access to everything.
Once it has been programmed and the functionality verified, you can complete the enclosure by add the side walls and top to have a fully finished enclosure. Here I'm using the ProtoStax Kit for Ultrasonic Sensor HC-SR04 to add the ultrasonic sensor to the enclosure wall. Once everything has been closed up, you can place it near your sink, plug it in, and use it to trigger your favorite jingles to assist and entertain you with your hand washing!
I have currently transcribed
- Happy Birthday to You
- Do-Re-Mi - Sound of Music
- We Will Rock You! - Queen
- Jeopardy! Theme music
These max out the memory on the Arduino, so I've enabled only 3 of them. However, it is possible to move the jingle transcriptions to PROGMEM memory so that it resides on Flash and the RAM is freed up.
To give you an appreciation for the differences, this program (with 3 melodies) took up 31% of program storage and 76% of dynamic memory on an Uno. With the above variables defined in PROGMEM, it occupied 32% of program space (that's only a slight increase in Flash memory usage with plenty more still available) and only 22% (down from 76%) of dynamic memory! That means you can easily add plenty of songs to this Touchless Musical Hand Wash Timer once you move things to PROGMEM! 😊
As with all my projects, I end with several suggestions to take the project further along to learn more and have fun along the way! I leave the moving to PROGMEM as an advanced exercise for you! (Since the music data is contained in arrays of structs, moving to PROGMEM is a more advanced undertaking but I highly recommend you learning how to do it).
You can find the project with full details at the ProtoStax Project Hub. Here is a direct link to the project -
Happy Making! 😊
Sridhar Rajagopal & The ProtoStax Team 😊