This Animated Christmas Tree indoor window display uses a combination of five WS2812 addressable pixel LED sticks for the Star. Sixteen individual pixel LEDs strung together for the Christmas tree lights and a green LED strip cut into lengths to make the tree outline.
The LEDs are controlled by a PIC18F25K22 microcontroller. The Star, Tree lights and Tree silhouette are independently animated with various patterns which combine to make a very varied effect.
Each of the three sets of LEDs have the sequence, speed, colour and number of repeats chosen at random from a set of programmed sequences. Some sequences fade gently from one pattern or colour to the next while others flash rapidly.
The LEDs were fitted to some clear plastic sheet but the star and string could instead be used to decorate a real Christmas tree.
Step 1: Parts
Parts for the display
- Clear plastic sheet. 2mm thick, 91cm (36") high x 52cm (20.5") wide. (You can use other cheaper materials if transparency is not required.)
- One 5 Meter Green LED strip (about 3M was needed) (SMD 3528 type) with 300 leds in total, (60 leds per meter) (cut-able every 3 leds). (available from various eBay sellers) (Cost about £2.15 including shipping)
- Five WS2812 8-LED pixel sticks (available from various eBay sellers). Mine were labelled CJMCU-2812-8 and cost about £1 each including shipping.
- Sixteen WS2812 LED pixels boards. (I made my own PCBs for these but they can be bought for about £2.75 for 20 from eBay)
- 12 Volt 4 Regulated Power Supply rated at at least 2 Amps (I used a 4 Amp type - these are sometimes supplied for use with LCD monitors)
- Ribbon cable to link the individual LED pixels into a string (I cut-up an old 40-way computer IDE cable to make this)
- Flexible hookup wire to connect the star etc.
- Clear adhesive tape to fix the wire and pixels to the plastic sheet.
- Optional piece of 2mm plastic sheet 16cm x 14cm to mount the star onto for easy removal if required (the star pixel sticks can be directly stuck to the main sheet if you don't intend to remove them)
- Double sided tape to attach the pixel sticks.
- M3 screws and nuts for attaching the controller PCB to the display.
Controller board parts
- Single sided copper-clad PCB 55mm x 70mm
- PIC18F25K22-I/SP microcontroller (available from Farnell, RS, Digikey, Mouser etc.)
- 3 Amp mini adjustable voltage regulator module (D-SUN) (adjusted to output 5V) This is available from various China eBay sellers for about £1 each or 10 items for about £4 (useful for other projects).
- 2.1mm pcb power jack socket
- ULN2803 IC. (Octal driver chip)
- IRFU9024 P-TYPE Mosfet power transistor (available cheaply from eBay)
- BC547 transistor
- 1.1 Amp resettable fuse (eBay or other sellers)
- 2 x 100uF 25v Electrolytic Capacitor
- 1 x 10uF 16v Electrolytic Capacitor
- 2 x 0.1uF 50v ceramic capacitor
- 2 x 470 Ohm resistor (0.125W)
1 x 1KOhm resistor (0.125W)
1 x 10KOhm resistor (0.125W)
1 x 47KOhm resistor (0.125W)
28 Pin 0.3" IC socket (for the microcontroller)
2.54mm pitch male header pins (cut a 9way , 2x 3way and 4x2way from a pin strip)
5 x 3way 2.54 mm pitch "Dupont" type female sockets and 15 x matching female crimp pins (eBay) (if these are not available, you can just solder the hookup wires to the board instead).
The other parts are not being used with the current firmware (Omit the ESP8266 WIFI module, 3.3V regulator and the associated resistors & capacitors) . (These may be supported by a later firmware)
Step 2: Making the Main Display
The display is intended to be hung inside a window. The only reason for it being clear plastic is so that it does not make the room dark during the day! (You could use a wooden sheet instead if you want)
The window that I will be using is a few inches narrower than the clear plastic sheet that I had available.
- I started by cutting the plastic sheet down to fit. My sheet was supplied covered by a protective plastic film and this meant it was easy to draw the cutting line with an indelible pen on the protective film (so that it wont leave any marks on the actual sheet later).
I left the height as supplied at 91cm (approx 36") and cut the width down to 52cm (approx 20.5") by clamping a long ruler to the sheet and gently scoring down the line carefully several times with a heavy duty utility knife (Stanley Knife).
Eventually the cut was deep enough to be able to snap the sheet cleanly by hand.
- Next the outline of the tree needs to be drawn onto the sheet (draw on the protective film only)
For this I first made a simple 2D plan using the free version of Sketchup. I dimensioned it so that the Green LED strip should fit by using lengths cut at the allowed cutting points (it can only be cut every 3 leds).
Then printed the design on an A4 sheet of paper (with all of the dimensions) which I used for marking out the lines on the plastic sheet.
- I then cut the four horizontal LED strip pieces (on the exact cutting marks) to make lengths of 50cm, 40cm, 30cm & 20cm
- Then I cut eight lengths of exactly 20cm for the diagonal sections.
- You may need to experiment with the placement of the strips on the sheet before fixing them in position.
- When you are happy they will fit, remove the protective plastic film from the other side of the sheet (leaving the one on the side with the markings) then peel off the backing from the LED strips and stick them in position. Make sure the +12V connection pads at the end of the strips are positioned adjacent so they can be easily wired together and the - connection pads can easily be soldered to without risk of shorting to any other pads. (see photos).
- Drill 3mm holes near the connection pads for routing wires.
- Connect together (solder) the +12V pads between each strip using short lengths of insulated wire to ensure no shorts to any other pads.
- Connect a length of wire from the +12V pad on the bottom strip long enough to reach the controller pcb. (carefully feed the wire through the drillhole to go to the rear of the board) (label the wire "+" with some tape or use a coloured wire)
- Wire together the - (minus) pads for each of the four pairs (left and right) diagonal strips then attach a wire from each pair long enough to reach the controller pcb. (carefully feed the wires through the drillhole to go to the rear of the board)
- Connect a wire to the - (minus) pad of each of the four horizontal strips. (carefully feed the wires through the drillhole to go to the rear of the board).
- Label the wires with 1 for the bottom strip, 2 for the first diagonal pair, 3 for the next horizontal and so on.
- The wires can now be bundled together and taped to the board neatly leaving enough wire free for attaching the connectors later.
Step 3: Make the Star
The Star is made with five sticks of WS2812 LEDs arranged with a 72 degree angle between each stick.
I made a template using Sketchup to help with the positioning of the sticks as they are slightly offset because the leds are not centred on the boards.
For my Star I used a separate plastic sheet so that I could easily detach it for testing the software using my breadboard. This is not necessary as the LED sticks can be attached to the main sheet using double sided tape.
- First place the LED sticks in approximate positions on a workbench and link the +5V connections to all five boards with short lengths of hookup wire.
- Repeat the above step for the 0V (Ground) connections.
- Connect the "out" pad on the top board to the "in" pad on the next board then repeat for each board.
- Connect hookup wires long enough to reach the controller pcb to the +5V, Ground and "In" pads on the top board. Label the wires then bundle them together ready for attaching connectors later.
- Print the Star template at 100% size and temporarily tape it in position to the rear of the plastic sheet.
- Attach double sided tape to the back of each LED stick and then stick each one in position using the template as a guide.
- Remove the template and fasten the star wires to the back of the sheet using clear tape
Step 4: Make the LED Lights String
The tree is decorated with a string of Sixteen WS2812B LEDs which can be taped to the display sheet.
WS2812B LEDs are available either in a 4 pin surface mount package or pre-assembled onto small pcbs from China eBay sellers.
Each LED needs a small 0.1uF capacitor across the power pins and the pre-assembled boards have this fitted.
I already had plenty of LEDs and didn't have time to order boards from China so decided to make my own.
Soldering each LED to a pcb can be fiddly and ideally requires tweezers and a magnifying glass to get the positioning perfect. (I recommend you get the pre-assembled type if possible and omit steps 1 -7).
- Etch a single-sided pcb with enough panellized individual pcbs to make 16 lights (I made a board with 32 in case of any errors)
- Cut the panel into 16 individual pcbs (for these I used a board that was only about 1mm thick and could be cut easily with metal shears)
- Check the pcb for etching errors (use some of the spare ones if found)
- Position a LED on the board using tweezers - see photo (one side is marked)
- Solder one lead and adjust the position with treezers while hot if needed.
- Solder the other 3 leds.
- Fit a 0.1uF 50V ceramic capacitor.
Now for the wiring-up. For this I used an old 40-Way computer IDE hard drive ribbon cable.
- Split the cable into thirteen sets of 3 way ribbons (use sharp cutters to nick the end of the cable then peel it back)
- Take one of the three way ribbons, use cutters to nick the end between each wire and peel back about 1.5cm on each wire.
- Remove about 0.5cm of insulation from the end of each wire and twist the wires together ready for inserting into the pcb holes or soldering to pcb pads.
- Cut the ribbon to about 8cm (3") in length and repeat the previous two steps on that end.
- Solder the ends to the three pads on each board and repeat until all 16 leds are done.
- On the last LED board solder 3 long lengths of hookup wire (about 30cm (12")) to the 5V, Ground and Input pads and mark them.
The LED string can either be attached to the tree now (using clear tape over each led board) or you can wait until you have tested that the string works OK before fixing it in place later.
Step 5: The Controller PCB
The controller is made from a single-sided copper pcb using the "toner transfer" method (various guides to doing this can be found elsewhere).
- Cut the pcb to size 55mm x 70mm approx
- Print the pdf pcb layout at 100% size onto your toner transfer sheet using your laser printer (I use the glossy yellow sheets available from China eBay sellers for good results).
- Drill the holes, most parts require a 0.8mm drill. The voltage regulator & PCB headers need a 1.1mm drill. The power jack needs 3 larger holes - drill them just big enough for the tags to pass through.
- Drill 4 mounting holes for m3 screws.
- Check the board tracks for any damage or shorts and fix them (mine had a few broken tracks where the toner didn't stick. I applied an etch resist pen but it didn't work properly for some reason).
Fit the PCB parts
Use an ESD anti-static wrist band while handling the semiconductors as they can be destroyed by static electricity! (particularly the MOSFET)
- Prepare the D-Sun voltage regulator module by soldering 4 x 2way male headers on the component side.
- Connect a 12 volt DC power supply to the D-Sun voltage regulator. Using an accurate voltmeter, adjust the variable resistor until the output voltage is as close to 5 Volts as possible. (If you can't get it exact, it is better to be slightly under 5V rather than over it).
- Solder the regulator module to the pcb as shown in the photo.
- Fit the rest of the soldered parts (excluding the parts for the WiFi module which is not yet being used). Ensure the correct polarity for capacitors and check the ULN2803 IC and transistors are inserted the correct way round.
- The MOSFET power transistor is very sensitive to static electricity - wear an ESD wristband to avoid damaging it.
- Solder the wire jumper (near the regulator module) The other wire jumper shown in the photo has been replaced with a 470 ohm resistor (to protect the microcontroller if the WS2812 leds go faulty).
- Do not fit the microcontroller yet - it has to be programmed first.
- Double check everything is fitted correctly and then plug-in a 12V DC supply. Measure the output voltage from the regulator to ensure it is still correct.
- Unplug the power supply.
Step 6: Program the Microcontroller
- Download the .HEX file. (The first firmware version is in the zip file along with all the other build documents) (Check for new firmware versions either here or on my website )
- Use either a Microchip Pickit2 or Pickit3 programmer. The Pickit3 is available from Microchip Direct. (The Pickit2 is now obsolete). Cheaper "Clone" versions are available from eBay which may or may not work.
- Download the standalone Pickit programming software from the Microchip website.
- The Pickit2 or 3 will need to be plugged into a programming adapter ZIF socket or connected to the IC programming pins via a breadboard. I made my own programming socket. They can be bought cheaply from eBay.
- Program and verify the microcontroller then insert it to the pcb socket ensuring it is fitted the correct way around (note it is the opposite way round to the ULN2803 IC which is not good pcb layout practice but does allow using a single-sided pcb without needing many wire jumpers).
Step 7: Attach Connectors
The connectors for the Star, Tree and string LEDs are made using crimped "Dupont" type 2.54mm pitch sockets available cheaply from eBay. Alternatively you can use 2.54mm pitch Molex connectors.
(You could omit these altogether and just solder the wires directly to the controller pcb although that could make it more difficult if you need to disconnect them for any fault finding etc.)
- Remove 0.5cm of insulation from the ends of each of the 3 wires.
- Use a crimp tool to attach a female socket pin to each wire.
- Insert the pins into a 3-way Dupont socket housing with the data wire going to the centre pin
- Mark the +5V socket pin so that it can be plugged-in to match the PCB header +5v pin.
Repeat the above steps exactly the same as the Star
Green Tree LEDs
These need 9 connectors (Use a 9-way Dupont socket if you have one - otherwise use 3 X 3-way sockets taped together)
- Crimp the female socket pins as before.
- Insert the 8 LED Cathode pins sequentially 1-8 into the Dupont socket housing
- Insert the single LED Anode pin (from the common +12V connectors of the strips) into the last socket housing hole and mark it so it can be plugged-in to match the "A" marking on the PCB header
Step 8: Testing
The testing will be done in 3 stages to avoid any possible damage.
Stage1 (The Green Tree LEDs)
- Attach the PCB to the display using four m3 screws and nuts.
- Carefully plug-in the 9-way Green tree LEDs plug ensuring the "A" anode wire matches the "A" marking on the PCB (the pin nearest to the MOSFET power transistor T1)
- Check your power supply is a 12 Volt regulated type rated for least 2 Amps (I used a 4 Amp one). It must have a 2.1mm jack plug (centre positive).
- Plug in the power jack and turn on.
The Green Tree LEDs should start to light sequentially from the top of the tree to the base until all are lit.
If they don't light at all - check all wiring of the leds and the pcb looking for any shorts, open circuits or other errors.
If they all light but out of sequence - the Dupont sockets must have been fitted in the wrong order. Use a small screwdriver to carefully lift the small plastic locking tab on each socket pin to allow it to be pulled out. Then re-insert them in the correct positions.
Stage 2 (The LED string)
Plug-in the 3-way socket for the 16 LED string (Ensure the +5v wire on the Dupont socket matches the +5v PCB header pin (the pin nearest to the 470 Ohm resistor R9)
Apply the power again.
This time you should see the Green Tree LEDs light in sequence as before, followed by the the String LEDs lighting in sequence (starting at the base until all 16 leds are lit).
If the string LEDs don't light at all - Check the plug is inserted correctly with the +5v matching the pcb pin. Check the wiring to the first LED is correct. Check for any shorts between the three LED wires.
If some, but not all leds light in sequence - check for a wiring error in the string after the last led that lit.
Stage 3 (The Star)
Plug-in the 3-way socket for the Star (Ensure the +5v wire on the Dupont socket matches the +5v PCB header pin (the pin nearest to the 100uF capacitor C3).
This time you should see the Green Tree LEDs light in sequence as before, followed by the the String LEDs lighting in sequence as before. Followed by each of the 5 LED sticks one at a time that form the star.
If the star LEDs don't light at all - Check the plug is inserted correctly with the +5v matching the pcb pin. Check the wiring to the first LED Stick is correct. Check for any shorts between the wiring going to each of the sticks.
If some, but not all sticks light in sequence - check for a wiring error to the stick after the last stick that lit.
If all the LEDs are working, sit back and enjoy the show!
Step 9: Future Developement...
I didn't have enough time to add all the intended features in time for this Christmas season.
Next year I may add some code to use a WiFi module to turn the display on/off at set times and maybe provide some configuration options via a web page.
There is enough code space left to add some more effects if I can think of them, or maybe improve the existing ones.