About 20 years ago, I walked into Ace Hardware and impulse-purchased a fiber-optic Christmas tree. It was skinny, about 6 feet tall, and designed to be put out in the yard.
I loved it. The way the colors swirled around it, changing in sections, was mesmerizing. If you’ve ever been to Spencer’s Gifts, back in the day, you’ll know what I mean. Eric refers to it as the “dope light” Christmas tree.
For the past twenty years, this little tree has been our tree. Bringing it out of the cardboard box is the beginning of Christmas and every Christmas Eve we leave it on all night long, waiting for the new day.
All of Kai’s childhood, this tree has defined Christmas. It’s an essential part of our holiday tradition.
This year, however, the lights stopped moving. When Eric and I investigated, we found that the motor turning the plastic disk to change the color had burned out, and worse—had melted the plastic stand. The transformer powering the tree was crazy hot—we probably just avoided a house fire.
The tree had gone dark. (Cat included for scale.)
Getting rid of the tree was NOT an option. I had to fix it.
I’m going to tell you what I did, as an adventure story, not a tutorial. There’s a lot I did over the past two nights that was guesswork, and… probably not the best way to do it. (If you don’t want the gory details of the project, feel free to scroll down to the end.)
I started by hopping on Adafruit.com and perusing their Neopixel options.
Neopixels are individually addressable programable LEDs. Which means that if you have a Neopixel strip with 30 LEDs, you can write a program to set of the color and brightness of each LED separately. You have complete control!
I read a lot of product pages, and took some measurements of the fiber-optic base of the tree (where all the fibers came together.)
Adafruit has a whole Neopixel guide, and there are lots of sample projects. However, none of those were “fix your twenty-year-old Christmas tree” and, a lot of the project write ups had assumed knowledge that I, um, didn’t have.
(Knitters, it was the equivalent of the single-line instruction “turn the heel” in old sock patterns.)
So I took my best guess and bought some stuff:
- Arduino Uno (the microcontroller)
- Neopixel Shield for the Uno (RGBW), 5×8 LED grid (comes with headers)
- 5V, 10A power supply (possibly overkill, but I wanted full brightness)
- 2-pin JST SM plug (a power cord that you can connect & disconnect)
- Female DC Power adapter (for the 5V power supply to plug into)
- 1000 micro-farad capacitor (to protect the neopixels from all this power)
- 470 ohm resistor (that I did not use)
On hand I already had:
- Soldering iron (and supplies)
- Wire stripper
- USB 2.0 cable Type A/B (for connecting the Arduino)
- Arduino IDE installed on my computer
Here’s my workbench
The white box on the left held the supplies for this project. The box on the right is for a different project.
My first challenge was figuring out how to connect the Neopixel shield to the Arduino Uno. The shield came with two types of headers, stacking and plain.
I wasn’t sure which to use, and was even more confused about what connecting the headers would do. Neopixels really only care about three connections: 5V power, ground, and pin 6 on the controller. The shield headers would connect the Neopixel shield to 32 pins on the Arduino. What the heck would that even do?
I toyed around with putting all the headers on, none of the headers, some of the headers. There was no place I found that said “dear reader, here’s all about headers when attaching a shield to an Arduino”. Finally, after looking at pictures of other people’s projects and zooming in, it looked like everyone was using all the headers, making a solid connection.
So I did, too. I chose the plain headers because they stuck up less than the stacking headers and it was important for this project for the LEDs to be as close as possible to the end of the tree where the fiber optic fibers came out.
I was very happy to have my “helping hands” doo-dad when soldering on the headers. I had one hand hold the header and the other the shield.
NEVER solder on headers this way. I learned the hard way that this is a recipe for soldering on your headers crooked, and then they won’t fit into the Arduino Uno (unless you get… creative with some needle-nose pliers.)
Next time, I’ll try setting the headers on or into a cardboard box and lay the shield on top, letting gravity hold it in place while I solder. I think that might help the headers come out straight. (If you have any killer header-soldering tips, please tell me them.)
Helping hands not so helpful, actually. 🙁
In addition to the plain headers, Adafruit included a terminal block for the Neopixel shield, so you can power the Neopixels with a bigger power supply than is provided by the Arduino. Because I wanted bright lights for my tree. I installed it. It’s the bit with the two tiny screws on the bottom of the board.
There was a bad moment where I couldn’t find a screwdriver that would fit those screws. Fortunately a glasses repair kit had the right size.
The cord coming off of the terminal block is half of the 2-pin JST SM plug. This isn’t essential to the project, but does make it easy to connect and disconnect the shield from the power cord. I was very happy I had added it later, as it gave me more slack when I went to install things in the tree.
This is an aside. These are the best wire strippers ever. I highly recommend them. I bought them for working on el-wire and have never regretted it. They’re so easy and accurate!
The other thing I dithered over was the instruction “cut the center of the solder jumper to the right of the terminal block”. This was something Adafruit said to do in order to power the Neopixel shield separately from the Arduino.
Um, what the heck does the solder jumper look like?
This was another place where everyone seemed to already know this so well, that they didn’t feel the need to explain. Looking closely at the shield I had two candidates of what to cut:
I mean, I was guessing they meant cut the line between the two gold pads—maybe? Of course there was the black thing directly beside the terminal. Maybe they meant that instead?
It was tense. I didn’t buy duplicates of anything. Cutting the wrong one would mean no lights on Christmas Eve. 🙁
I Googled, I search on YouTube. I squinted at tiny project pictures that I’d zoomed up to maximum. And it seemed like the gold pads were the thing.
So I took an Exacto knife out and cut the link.
And then, how do I connect pin 6 to the Arduino? I just guessed that maybe connecting the shield headers to the Arduino would do that automatically? Because that’s how I’d design it.
(There was a lot of guessing going on at that point.)
This is what the shield looked like after I’d soldered on the headers, cut the jumper, and attached the power adapter to the terminal.
And then, the moment of truth. I finagled the wonky headers and put the shield onto the Arduino, connected the shield’s terminal to the 5V power supply, attached the USB cable to the computer, opened the Arduino IDE, and uploaded some code.
Many hours in, many guesses… the moment of truth…
This was a very happy moment for me. All the LEDs lit! Nothing blew up!
The next bit was to write the software that would animate the tree lights. I was trying to replicate this: a light that shines through an spinning plastic disk that has been painted different translucent colors.
What I soon realized was that animating analog spinning on a 5×8 grid was a non-trivial coding problem. This was around 3:30am.
So I started plinking at it.
I mapped out the grid into blocks to simplify things, and recreate the size of blocks the original tree had. (I crossed off the pixels on the sides because they didn’t fit the round base of the tree.)
I could change the color of the blocks, but that would have created a strobe effect on the tree, and I wanted the smooth color transitions of the original.
After some pondering, I realized that what I needed was a fade transition from one color to another. I couldn’t find a fade library for Neopixels, so I wrote some fade functions on the fly. (Not bad for someone who hasn’t coded C in at least five years.)
That got me the whole tree fading from one color to another. Which was still not the effect I wanted. I wanted my color blocks, darn it!
Then I realized that by combining the code I’d designed while playing with the blocks, with the fade code, I’d get exactly what I wanted!
[It’s not the most elegant code ever. It was 4:30am on Christmas Eve and I had a deadline! :)]
Here’s a wee video of the color fading in and out. I’ve put several pieces of paper over the Neopixel shield because it was so bright!
At this point I discovered that NOT cutting the jumper gold pads would have enabled the Arduino to run off the same huge power block as the Neopixel shield. In other words, I could have one power cord running to my tree instead of two. Oy! I wanted one cord. So I squeezed my soldering iron into the very tiny space and (with shaking hands) managed to reconnect the pads without soldering them to anything else. Whew!
Note: Actually, I’m not sure this was a mistake to do it this way. I read somewhere in my research that connecting the Arduino to USB power while it was also connected to the 5V power supply could blow things up. So maybe I did it right, waiting until the final code was uploaded to reconnect it?
I removed the old electronics from the Christmas tree stand.
3D printed a holder for the Arduino Uno (Thingaverse thing by sceadu_design is here). I didn’t have the size screws I needed to attach it, though it did give me something to stick the duct tape to. (You knew duct tape would come into this at some point… didn’t you?)
I used tape* to stick the LED assembly into the tree base. *(actually gaffer tape from my friend Ruth, so I could remove it later if I wanted to update the code.)
And put the thing all together…
A glowing tree with animation! In time for Christmas Eve night. I made so many guesses on this that it was, indeed, a miracle that it all worked.
And even better, the LEDs draw much less power and are quieter than the old motor-driven electronics. The tree has been upgraded! Here’s hoping it lasts another twenty years. 🙂