Program wooden mini-Christmas trees to sparkle and sing
By Corey Beckett
Back in 2005 when I was 12, I decided to make a number of special Christmas presents: miniature wooden trees that flashed lights and played Christmas tunes.
That original version of the project used 3 mm light-emitting diodes (LEDs) and no printed circuit board. Because of its size, it was tricky to wire and not so easy for a novice to construct. But the version of the project being followed here has been updated and adapted for easy construction.
I made these trees from 6 mm-thick customwood but anything suitable can be used. The trunk is made wide enough to hide the battery box which attaches at right angles to the shape at the bottom so it can act as a support to hold up the tree.
I made my tree 200 mm high and shaped it with four progressively wider triangular bases or “skirts” ranging from 51 mm-wide at the top to 130mm-wide at the bottom. You can obviously make the dimensions to suit yourself.
Construction
I prefer to make a cardboard template rather than sticking paper onto wood. I marked Drilling holes for LEDs. I marked the tree shape onto the customwood before checking this and cutting the tree out with a jigsaw. Drill the LED holes to suit the size of the LEDs (in this case 5 mm) and use a countersink tool to remove the burr on the rear. A quick sand cleaned up both sides and a can of green paint made them look like trees.
You can add more detail or paint the base a different colour but the novelty is the LEDs and the tunes.
LEDs
There are 18 LEDs in total, six each of green, red and yellow colours. Because the 3 x AA 1.5v batteries give a total voltage of only 4.5v, it was necessary to wire two LEDs in series, making three pairs in each colour. The nine separate “pairs” have a small current-limiting resistor and are wired to the collector of a transistor on the CHI040 board.
You will need to orientate the first LED in each pair to allow the anodes (this is the longer lead or the lead away from the fl at of the mounting ring) to be joined. This is usually easier if the anodes are closest to the outside. Press the LEDs in the holes you have drilled until the mounting ring is against the board. This will ensure the LED protrudes past the front of the tree.
Wiring
It is easiest if you draw the wiring prior to doing any forming. Use the template and some coloured pens to make a paper representation of the rear of the tree.
I started by picking where the three “pairs” of a particular colour would meet before bending and forming the LED leads. You need to be careful about the length of the leads. When I designed the new size, we increased this to compensate for the larger 5 mm LEDs and forgot about increasing the length of the LED leads, too. The result is that some of these leads require short extensions to enable them to join (use the off-cuts of other LEDs).
Take note of the tree shape as you will need to bend some leads to ensure that they stay hidden. When you are happy with the layout, start soldering the leads and then add short pieces of wire to join the commons together.
Add the 9 x 100 ohm series resistors to the cathode of the second LED in each pair, leaving a small length to solder to the wire that goes to the circuit board. You can test your wiring by using the battery pack and some clip leads. The +ve (red) should go to the common and the –ve (black) to the series resistors. If you have all six LEDs of the one colour going, then move on to the next colour.
Circuit board
We used the PICAXE CHI040 board which contains a PICAXE 08 programming socket and the transistors need-ed to drive the LEDs. A switch is fitted to turn the sound off and a piezo buzzer added to Output 2 to play the tunes. Originally there was no switch, so pin3 was low. I chose to add the ON detection to stop the music playing endlessly (ON = silent). If this is the case, the program then allows the patterns of light from the LEDs to play silently in sequence.
One wire link across Tr3 is required, and the 1K ohm resistor replaced with a zero ohm or link, as shown on the board photos. The buzzer is wired with the +ve into the centre pin of Tr3, and the –ve to the cathode of D3.
Switch
The switch is anything that you have. In this case I modified an existing slide switch by cutting off the mounting lugs and all but two pins. This is fitted across input 0 on the board.
The completed board is wired to the LEDs using Outputs 0, 1, and 4, and to the battery box.
Attachment
The battery box holds the three AA batteries and has an on/off switch. I used velcro to attach the battery box to the tree and the board to the battery box. Place a strip of Velcro or some spots on the face of the battery box that isn’t the cover, nearest the on/off switch, and put the attaching strip on the tree, making sure it is hidden by the trunk. Some more Velcro on the side opposite the switch allows the board to be attached to the rear of the battery box.
Lights and music
For lights and music together, the PICAXE 08M contains three built-in tunes (Jingle Bells, Silent Night and Rudolph the Red-nosed Reindeer). You can also program it to fl ash the LEDs on Outputs 0 and 4 while the tunes play.
As you can add your own tunes for PICAXE to play, I contributed Merry Christmas and Deck the Halls as well as three patterns for the LEDs to follow. In the program, the numbers ($22, $27…) represent each note you put in. I added three patterns for fl ashing the LEDs while the songs played. The listing is available on the website to download which will save some typing.
Patterns
At the beginning, the program monitors whether you want the tunes to play. The switch controlling the sounds is detected at the start of each LED pattern and at the end of each tune. The program checks to see if the switch is On (if pin3 = 1 then buzzer_off ) which indicates silence. If so, it jumps to the first pattern for the LEDs.
The lights play according to the fol-lowing repeating patterns:
Pattern 1, repeating: Turns each co-lour on in sequence and then off in sequence (20 seconds).
Pattern 2, repeating: Alternates each colour (20 seconds).
Pattern 3, repeating: Turns all LEDs on and then all off one second later (20 seconds).
The program returns to Main: and be-gins all over again.
Tunes
During the patterns of LED displays, the switch is checked each time it loops to see whether the sound should be started. If the switch is Off ( if pin3 = 0 then exit ), this is the signal to jump to Buzzer_On which will start the sequence of music.
Buzzer_On turns on Output 1 and starts playing Merry Christmas while fl ashing the LEDs on Output 0 and 4 because of the tune 3, part of the command. When Tune 1 and Tune 2 which I added have finished playing, the program jumps to the built-in tunes. We use play X, 3, where X is the inbuilt tune number and the 3 tells the PICAXE to fl ash the LEDs at Output 0 and 4 as the music plays. After each tune has played, the pro-gram checks to see if the BUZZER switch is off or on.
If it’s still Off, the next tune sounds. At the end of the fifth tune, the program checks the switch and if it is still OFF returns to Main: and starts again.
If you want only the LEDs to perform, you instruct the program to leave the switch ON which makes the buzzer silent.
Presents
When I first built these as presents several years ago, they worked great during testing. However, it was only when those happy to receive the presents had left the trees and music on for some time that they found the continual tunes formed a sort of psychological torture. The trees were quickly recalled for the switch to be added. That’s why this present version is programmed in a better way.
For that really “special” present, you could alter the program to play the tunes many times before detecting the off-switch. However, you might find your offer of a present the following year a bit less welcome.
DAD WRITES Christmas tree schematic.
Corey just turned 12 when he did this project so he had some limitations with code. Programming Editor (the software) has expanded since then and he has used at least one of the new instructions to update it. The software for PICAXE is free to download and the registration simply gives you the password. The download and installation also includes the datasheets for the various boards, manuals, and lots of examples.
The PICAXE site has some 72 Christmas tunes to download at
(http://www.rev-ed.co.uk/software/christmas_1.zip) as well as 15 anthems, 48 TV Themes and 800 other pieces of music.
If you want to add your own tunes, there’s a very useful utility called Tune Wizard to help you with the notes required when you install the Programming Editor Software (http://www.rev-ed.co.uk/software/bas805.exe).