Christmas is coming, so I was wondering if there was an interesting project that I could do that could be a gift or just be entertaining during the holidays. As luck would have it, ModLab had a day-long workshop called Hack UR Baubles, run by Ottawa hackers Michael Grant and Megan Smith, to construct a programmable Christmas tree ornament that can play sound, light LEDs and has a number of potential inputs.
This workshop was the perfect entry point for me into constructing some basic electronics. When I arrived, I had a kit of materials waiting for me, including the custom designed PCB for the project, resisters, capacitors, ICs, inputs, outputs, and a variety of other necessities.
The objective for the day was to follow the assembly instructions, and Michael and Megan were on hand to help us through. This was my first time soldering onto a PCB, but I found it to be quite easy to get into the swing of things. Basically, just stick the wires of the components through the holes, solder just enough to ensure a solid contact, and then snip the wires so the join is as short as possible.
First up were the numerous resistors, which were quite fiddly as they fall out when you turn the PCB over to solder them. I found the best strategy was to bend all the resisters first, then insert them into the proper holes, put a magazine over the top of the PCB, and then flip, using the magazine to hold the resisters in all at once.
After the resisters, the rest of the components followed, until the entire board was full. I chose to build a battery powered device, which involved riveting a battery holder onto the back of the PCB. While it looks a bit of a mess and hard to follow, it is a lot easier to understand the structure of the circuit by looking at the schematic.
The next physical step was to connect the LEDs to the PCB. There are seven LED outputs around the edge of the PCB, which can be seen as the circle-square pairs. There was quite a selection of LEDs, which were largely just strings of Christmas tree lights that had been cut into pieces. I selected four standards LED christmas lights, two white snow flakes, and a large bulb shaped LED that I thought looked like Rudolph’s nose. Before soldering onto the PCB, we first had to determine the polarity of the LEDs and then solder the end that went to the negative side of the battery to the square hole on the PCB; the positive side went to the circle hole.
The final step was to program the chip. For this, we needed a serial cable of which there were a few floating around, which would get attached to a set of holes on the PCB and to my computer via USB. There were several different sketches that we could download, and I tried the one that plays a song using the Nokia ring tones (RTTTL) and flashes the different LED channels simultaneously.
I initially had a problem uploading the sketch to my Bauble from the Arduino IDE, and we thought it may be a driver problem with my MacBook Pro. Turned out the cause was that the batteries were dead! Sometimes the simplest solution is the answer – the classic making sure it is plugged in and turned on if you have a problem.
After getting it to run and play a number of songs (including Star Wars), I wanted to play something that was more Christmas-like. I settled on Greensleaves, largely because I love the song and it reminds me of this time of year.
To do so, I commented out the other songs and added this line to the code in the sketch:
char *song = “Greensleaves:d=4,o=5,b=140:g,2a#,c6,d.6,8d#6,d6,2c6,a,f.,8g,a,2a#,g,g.,8f,g,2a,f,2d,g,2a#,c6,d.6,8e6,d6,2c6,a,f.,8g,a,a#.,8a,g,f#.,8e,f#,2g”;
And it worked! See it in action: