Having recently built a 4x4x4 LED cube, I thought it might be interesting to apply the same techniques to building an LED Christmas tree. I used a single white LED as the 'star' and then a mix of red and green LEDs forming the sides. Initially I thought to make the tree star shaped in cross-section, but eventually realized that a six sided star would be easier as the supports could be made out of two identical triangles.
I used an Arduino to control the light patterns with a sketch loosely based on some sketches for a 3x3x3 LED cube.
What you are going to need:
1 medium white LED
15 diffused red LEDs
15 diffused green LEDs
6 resistors (values depend on the LEDs chosen, I used three 10 ohm and three 1k ohm)
some medium gauge copper wire
some fine gauge copper wire
an Arduino, I used a Freeduino
an Arduino compatable prototype shield
some male headers to attach the protoshield to the Arduino
Step 1: Building the Frames
I then built a second identical triangle. The two triangles were soldered together to form a six sided star.
Four more stars were made similarly by decreasing the distance between the nails by about 1.3 cm per layer. The smallest layer was pretty tiny and I might try decreasing the amount of change per layer next time.
Step 2: Soldering on the LEDs
I used a coin cell to make sure all of the LEDs still lit and then cut off the extra length of anode. The last picture shows the finished star right side up and sitting on the cathodes of the six LEDs.
Step 3: Soldering the Layers
Support the white LED above the top layer of the tree. Solder its cathode to the cathode of one of the six LEDs in the top layer. Leave the anode unattached for now.
Step 4: Connecting to the Prototype Board
Bend the cathodes from the bottom layer of the tree inward. Then bend each of the leads to find a hole on the prototype board. It's best if the holes chosen are already connected to another hole. This will make the connections to the Arduino easier, but you will probably not be able to do that in all cases. Once all six of the cathodes are inserted to the protoboard solder them in place.
Take six lengths of small gauge copper wire. One of these gets soldered to the anode of the white LED at the top of the tree. The other end gets soldered to a free connection on the prototype board. For the other five lengths, form a hook in one end and solder it to one of the copper frames. There should be one lead per level. Solder the other end to a free spot on the protoboard. Just make sure that none of these leads or the cathodes are connected to each other on the protoboard.
You will need to choose appropriate resistors for your LEDs. I found that 10 ohm resistors worked well for the green LEDs and 1k ohm worked well with the red LEDs. This gave approximately the same light level out of the LEDs and kept the current flow low enough to avoid taxing the Arduino.
Since the resistors were matched to the color of the LEDs they had to be connected to the 'columns', that is the cathodes. To do this I soldered one end to each of the legs of the columns and the other end to one of the digital pins on the protoboard. Just to make life simpler I used digital pins 8 through 13. As you can see in the photos I did this on the top of the protoboard. I also tried to keep them sequential as one moves around the sides of the tree. This makes programming a bit simpler.
I used small gauge wire to connect the layers to the analog pins of the protoboard. Since the analog pins can function as digital pins this kept the two sets of lines separate and makes it a bit less confusing. I connected the top layer (the white LED) to A0, I then moved down the array with layer two attached to A1 and so on. As you can see I ran these leads on the bottom of the protoboard. Again this was to keep things cleaner.
Step 5: Upload the Code
Since all of the LEDs in a column are attached by their cathodes which are attached to one of the digital pins and all of the anodes in a layer are connected together and to one of the analog pins any LED can be lit by setting its cathode high and its anode low. This does limit how many LEDs can be controlled at one time since a three dimensional system is being controlled by two variables. This can be gotten around by using POV (peristance of vision) but that's beyond my ability to program. See some of the 4x4x4 LED cube Instructables for examples.
Enjoy your LED xmas tree. If you get motivated to write better code please post it in the comments section.
Thanks for playing.