It's that time of year: December. And in my neighbourhood, everyone's decorating their house and windows with some Christmas lights. This time, I decided to build something custom, unique, using an ESP8266 module and just a couple of RGB LEDs. You can do this same build using an Arduino (Uno/Pro) module, but with the ESP module you also get it wifi-enabled, for remote control, scheduled turn on/off.
- ESP8266 (NodeMCU module) or Arduino Uno/Pro/Pro Mini/etc. This tutorial is for ESP8266, but it's also applicable to the others
- Individually addressable RGB LED light strip (WS2812 chips), recommended: 60 RGB LEDs/meter, 1 meter piece
- Some wires and soldering
- A long micro-USB cable (it is USB powered)
- Either wood or just a carton for the frame
- Arduino IDE for software development (see sample code at the end of instructables)
The nice thing about the WS2812 RGB LED strip is that these, now affordable LED modules are individually addressable and chained, so you just have to make sure the "data" line is connected from one to another. It's a very convenient component for the tree, because after cutting up the LED strip into pieces, you only have to chain them with one wire. The other two connections (+5V and ground), you can connect anywhere.
For the addressing from code, you can see that the addresses of the pixels start at 0 (closest to the base of the tree) and go on to 42, for a total of 43 LEDs. You are of course free to use more or less LEDs, but then you have to modify the code.
The power consumption for my 43 LED setup is about 360 mA max with the current code, but I am not maxxing out the LEDs. If you would turn on all the LEDs, full power, it would probable be above 1A, so watch out!
The current code is a simple one, it sets all the LEDs to green, and then changes a pixel to one of the 6 palette colors every 0.5 seconds. You are free to modify it and experiment with any complex pattern.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Cut the LED Strip
First, lay out the RGB LED strip and cut it to size, to form the tree.
I preferred to have 15 LEDs as the trunk (vertical), and then 2 + 2, 4 + 4, 8 + 8 LEDs for the branches, but you can have more or less. Make sure to only cut the strip at the copper pads (cut signs).
Step 2: Creating the Frame
You could just use a piece of cardboard, but I had some (balsa) wood lying around and I think it looks just slightly better, so I used that. Draw the outline on a piece of A4 from the previous step (where you cut the LEDs), and cut some wood pieces to that size. Then use hot glue to put it all together.
Step 3: Attaching the LED Strips to the Frame
The LED strips have an adhesive on the back. Use that to attach the strips to the frame.
Do not attach the trunk (vertical) piece yet, that will be only the last step after wiring up almost all of it.
Note the direction arrows on the strip - that is the direction of the chaining/data! You should have DI (data in) on the right branch, right hand side, and DO (data out) on the left branch, left hand side. We want to have a nice and easy chain of all these LEDs. Note, power (+5V, GND) will not be chained.
Step 4: Wiring It Up
We want to chain data, so that means our data wires will go from an upper left branch to a lower right. And of course we connect all 3 wires in the middle, where a left + right branch meets.
When this is done, we must make sure to power all bits, for that, I ran a black wire on the left hand side (vertical) for GND and on the right hand side for +5V.
Step 5: Connecting to ESP8266 and Uploading Sketch
Connect the pins from ESP8266:
- +5V (VIN) - to LED strip +5V
- GND - to LED strip GND
- D7 to LED strip Data
Note: if you use Arduino Uno/Pro, this pin might be different, just make sure that it matches the source code.
Start the Arduino IDE, create/load the source code (attached) in it, then make sure the Arduino IDE is configured with the correct settings (port, device type, speed), then press Compile + Upload.
When it's done, the LED strip will light and begin displaying patterns. You might need to add the Adafruit - Neopixel library to the Arduino IDE (v1.8+). You can also modify the code to display different patterns, feel free to experiment.