Light up musical Christmas Card
Three days before Christmas, just as I was falling asleep, I had a vision of a led Christmas tree card. I imagined it would have a number of charliplexed LED’s blinking in a decorative fashion. I had a few ATtiny85 microcontrollers on hand from prior projects, and decided to give it a go.
First off came the experimentation with the Charliplex circuit. I have not played with charlies in a while. A quick google search revealed some interesting sample code specifically written for the ’85. It has also been a long time since I used my ISP programmer, so I needed a quick reference of the pinout diagrams, for and the 6 pin ISP programming connector and the ISP pins on the ATtiny.
First off was locating some spare parts:
- 5mm Red and Green LEDs
- Atmet Tiny85
- USBTinyISP programmer
- Small flat speaker
- momentary push button
Reference Code used:
The ISP Connections:
Once the ISP Pins were plugged into the micro with jumpers, it was time to program the ATTiny.
Step 1 – Upload Bootloader and select ATtiny85 board, 1 mhz.
Step 2 – Upload simple “Blink” Program
Step 3 – use sample Charliplex code and LEDs
A few quick jumpers on a breadboard yielded some blinkenlights.
First, we try out the sample Charliplex Code
Video – Charliplex code sample
Next, we locate some code that can play back simple tones using a single pin of the ATtiny.
Connecting the speaker is simple
Video: a simple Chromatic scale
Next was determining what notes sounded like Christmas Time Is Here from Charlie Brown Christmas.
I played around with a keyboard to find simple tones (not chords) that sound similar to this tune.
To my untuned, musically challenged ear, the beginning sounds somewhat like A, F , F, D, D.
To get the timing right, I added a new “note” called Z which results in an inaudible frequency when played.
I included note Z to add delays between notes.
The final result sounds like this
Video: Christmas Time Is Here
Because code generated using the Arduino IDE is single threaded, you can only play music or flash LEDs using the above code, not both at the same time. Also…this was 2 days before Christmas, I simply did not have enough time to figure out how to do it the right way. I opted for the “hacky” solution, simply alternating between led lights and tunes. Alternativly, I did experiment with two chips, one playing the tunes and one flashing the lights, as seen in the following video.
Video: two AtTiny 85 chips
Next, I assembled the basic card structure ( a Christmas Tree with LEDs) and wired up 4 pairs of LEDs, arranged with the reverse polarity of its sibling.
Each row has two LED pairs. These pairs will be charliplexed to 4 pins on the micro.
The hookup is roughly as follows for each pair, plus one single LED.
And the messy wiring
I added a simple momentary push button switch to connect the 3v lithium cell to power the circuit. I taped a penny behind it for rigidity.
Finished product – “Christmas Time is Here” with LEDs
Mom loved it.