The nice thing about Christmas holidays is that you actually have the time to make shower thoughts a reality.
- 1 × Arduino Uno. It will also work on other Arduinos (subject to pin number changes), and should also work on other boards, as long as there are 3 digital GPIO pins that can sink ~30mA, 1 PWM output pin, and a 5V rail.
- 3 × red LEDs, 3 × yellow LEDs and 3 × green LEDs. I’m using whatever comes with the Arduino kit. It should work if it drops ~2V drawing ~10mA each. The code can be easily adapted if you want to add more colours, as long as you have three LEDs for each colour.
- 3 × 100Ω resistors. I don’t have them so I’m using two 220Ω resistors in parallel to replace each 100Ω.
- 1 × passive buzzer or speaker. I’m using a KC-1206 which came with the Arduino kit, but I’ve also tested an AST-030C0MR-R (which came with the Chaotic Oscillator kit) and a 4Ω 3” speaker (part number starts with EAS8 but the rest is illegibe due to rust) which I scavenged from an FM radio receiver.
- A breadboard and a bunch of breadboard wires.
- A power supply. I’m using USB.
A score for the song was looked up and its melody was written out as
an array of the standard pitches in
has the same length as
song and denotes the relative length of
int durationScaleFactor controls the tempo of the song.