This 4-foot tall structure is a prototype for a larger LED structure we’re building this year that we’re calling the “Tree of Light”. The actual final structure will be somewhere around 35-40 ft tall, but since it will take time to build, we decided to build a smaller prototype, so that I can start writing code and figuring out the algorithms for the light patterns.
We want the LEDs to be arranged in this flowery shape on each disc. The first step is to gather some measurements based on the radius of each disc. There are two important lengths here which I’m calling p1
(length of the “inner petal” edge) and p2
(length of the “outer petal” edge)
Variables:
- radius of the disc
r
- length of edge of inner petal
p1 = r / 2 / sin(60°)
* - length of edge of outer petal
p2 = 0.65 * p1
**
* I won’t pretend I figured this out without looking it up… thank you stackexchange
** I figured out this 0.65
in a silly way. Instead of working out the geometry, I coded the above diagram with JavaScript in an HTML canvas, and logged out ratio of p2
relative to p1
With all these measurements, I drew the pattern onto each disc, and cut pieces of LED strip to fit along these lines. As I did that, I recorded the number of LEDs in p1
and p2
for each disc in a spreadsheet, and when I was done I had cut a total of 1284 LEDs.
I needed to figure out how to send the wires from the ESP32 board and how to route all the segments of LED strip around each petal. The ESP32 board (which will live at the top center of the model) has 19 output pins. My goals here were to stay within ≤19 pins, minimize the amount of wire used, and also hide the wires to keep it nice-looking.
Here’s what that strip looks like all spread out:
Starting at the center of the disc, the LED strip will trace one inner and one outer petal, and then the pattern will repeat starting with the next inner petal. At first I planned to bend the LED strips on the 120 and 90 degree turns, but the LED strip felt too fragile, and wouldn’t sit flat enough. So I soldered short little jumper wires between each straight segment.
How big does the power supply need to be?I happened to have this 5V power supply lying around. Here’s how I calculated whether it would be big enough:
- Power Supply: 300W
- 1 meter LEDs (60 LEDs/m): 12W (listed on package)
- per LED: 0.2W (12W / 60 LEDs)
- all LEDs (1284 LEDs): 256.8W (0.2W * 1284 LEDs)
- all LEDs x 10%*: 282.48W (256.8W * 1.1)
* This YouTube video recommended getting a power supply that has a capacity at least 10% higher than the max needed.
Where to inject power?1284 LEDs is obviously too many LEDs to string together in one strand. To figure out how often I would need to inject power, I unrolled one of the LED strips I bought and set the whole thing to white on full brightness. It looked obviously yellow around 2/3rds of the way down the strip, after ~200 LEDs. So I injected power every 200 LEDs.
The diagram below shows how all 1284 LEDs are split up into groups of ~200. I routed wires to each group to inject power. Each group also has a single data pin on the ESP32. Some groups have less than 200 because I wanted to start each new group of 200 at the beginning of the petal right near the center rod. It worked out to be 7 groups of LEDs:
- ESP32 Pin 2 (dark green) : 200 LEDs
- ESP32 Pin 4 (light green) : 184 LEDs
- ESP32 Pin 5 (yellow) : 196 LEDs
- ESP32 Pin 12 (light orange) : 202 LEDs
- ESP32 Pin 13 (dark orange) : 198 LEDs
- ESP32 Pin 14 (red) : 190 LEDs
- ESP32 Pin 18 (brown) : 114 LEDs
- Total: 1284 LEDs
The trickiest part with the glueing was that I had to glue the LED strips on in a specific order, to make sure that the wires got glued down underneath the LED strips.
The power supply and ESP32 live on the top of the tree. I ran wires from there down through little holes we drilled in the plexiglass to the beginning of each LED group, and connected to the strips with 3-pin connectors. The LED groups that start on one disc and end on the next disc are also connected together with the 3-pin connectors.
Setting each disc to a different color involved figuring out how to map LEDs from pins to discs. I ended up making one big long array of the LEDs for each disc chained together. Then I created a simple struct
for each disc that stored a pointer to that disc’s LEDs, so I can access them per-disc. Check out the code snippets in the code section below!
I've programmed 12 different patterns so far for these LEDs. This video will run through and demonstrate them one at a time for about 10 seconds each.
Comments