Remember my animated LED Easter basket? It’s back… in pog Christmas form.
To recap: In 2020 maths YouTuber Matt Parker made a video about his animated LED Christmas tree. I saw that video again recently and inspired me to try to do the same thing. Two things made Parker’s tree cooler than most. One, he used individually addressable LEDs controlled by a Raspberry Pi computer. This meant he wasn’t limited to just a static sequence of colors or a factory-set twinkle pattern; he could set the exact color of every LED exactly how he liked multiple times per second. Two, he made a 3D map of all the LEDs so he could address them geometrically rather than by their order on the strand. This made it possible to create much cooler looking animations.
So that was my target.
Hardware
I already had a couple of Raspberry Pis so that part was easy. Then of course I needed some lights. These lights from ALITOVE seemed to be what most people who do this kind of thing use so that’s what I went with. I powered my Easter basket project with a 5V wall wart from my collection of electronic detritus, but since these LEDs use 12 volts and since there were 500 of them not 50 I had to buy a 12V power supply. It has served me very well and I haven’t killed myself with it even once, but it’s a scary looking bare metal thing and I admit that I had it couple days before I was brave enough to wire it up and plug it in.
What else? While the lights run off of 12V power they expect to see 5V on the data line and the Pi operates at 3.3V, so I also needed a little level shifter chip to do that translation. Other than that it was just wires and connectors. I did have to throw in one resistor to shut up noise on the data line, but I already had that. When all was said and done it came together in the elegant and not-at-all unsafe form factor you see below.

In addition to all of the pieces that interface directly with the Pi and the lights, I also had to use a webcam and laptop to capture the images to do the 3D mapping of the LEDs. Because mapping involved finding the brightest spot in a picture of the tree with a single LED lit, I needed the room to be dark. I tried mightily to make my well-lit living room into a suitable studio (see below), but the sun it turns out is pretty bright compared to consumer grade LEDs and I never really got satisfactory results unless I did the mapping procedure at night.

By the way, the little rug you see in these pictures is not just there to tie the room together. Mapping the lights in 3D requires capturing images of the tree from all four sides, so the rug played the vital role as an ersatz lazy Susan, perhaps the laziest Susan ever to perform that job.
Software
It’s at GitHub; if you want to know more details check out the README there, though fair warning that’s pretty terse as well. I wrote separate Python scripts to capture the LED data, to massage it into a more usable form, to generate animations with the 3D data, and to play the animations on the Pi (and thus on the tree). It is possible to run the Python in real time for simple animations, but the older Pi I was using started to choke if you gave it too much computation to do too fast, which is why I designed it to generate the animation data on a beefier computer.
Results
Here are couple of the animations I managed to create with just a few hours of coding.
Pride Flag
You could almost do this without the 3D mapping since the layers basically follow the way the strands are wrapped, but it’s an easy proof of concept and the colors are nice.
USA! USA! USA!
Or possibly La France! La France! La France! Either way the vertical bars here demonstrate the 3D mapping.
Candy Cane
One of my favorites. I’m proud of how this one turned out.
Sine Wave
It suffers a bit from the low resolution but you can basically see it.
Hybrid
The way I wrote the animation system makes it easy to combine and layer effects, so here are the candy cane stripes and the sine wave together. More of a proof of concept than something attractive on its own.
Future Plans
I can obviously design more and more animations until the cows come home so you may see a few more between now and New Years. Thinking ahead to 2025, I have some ideas. Priority number one is getting the electronics and power into a neater and safer package. I may also try to replace the Pi with an ESP32 board, as those things are hella cheap. Priority two is designing a better way to rotate the tree during mapping than a &@(#!*$ rug. Doing it that way was a huge pain in the ass and I’m certain introduced a lot of error into the process. I think I can also find better (and perhaps more) LED strings to give myself a nicer canvas to work on. If I do that’ll mean these 500 lights are available for something else.