Introduction: A Charlieplexed Christmas Tree
Welcome to my first Instructable. I'd appreciate any constructive criticism you care to leave in the comments, but please be gentle.
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 decided to make the tree with five layers and a single white LED on top. This meant I needed to construct 5 six sided stars to support the different layers. I decided on a base 8 cm across which implied that the stars should decrease around 1.3 cm per layer. I then measured out an 8 cm equilateral triangle on a piece of hard wood and drove in three nails at the vertices. I then bent some medium gauge copper wire around the nails to form a triangle. I cut off the excess wire and soldered the two ends together.
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 wanted three green and three red LEDs per layer. I soldered the anode (the shorter leg) of each LED to the point of the star. I found it was easiest to hang the LED from a bend in the anode using a clamp to hold the LED in place. The cathode of the LED was allowed to point upwards. These cathodes will form the connections between the layers.
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
I learned the hard way that it's easiest to solder from top to bottom. Position the two layers so that the tails of the upper cathodes are in contact with the next layer's cathodes just below the body of the LED. Carefully solder the two cathodes together. I lined up all the green LEDs and all of the red LEDs to make selecting appropriate resistors easier. Use a coin cell to make sure all of the LEDs still function.
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
Solder the male headers to the underside of the prototype board to make connection with your Arduino. It helps to use the female headers on the Arduino as a guide to soldering.
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
Connect your protoshield to your Arduino and upload the code below. I'm not much of a programmer so the code is very crude. I've seen much better programs to control LED arrays but, to be honest, I didn't understand them so I couldn't adapt them to this application.
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.