Michelle
Published

A "Tree of Light" Prototype

A "Tree of Light" with 9 plexiglass discs each adorned with LEDs arranged in a flower shape.

BeginnerShowcase (no instructions)851

Things used in this project

Hardware components

Espressif ESP32-WROVER-E
×1
WS2812B LED Strip 16.4ft 300 LED Pixel
×5
5V 60A 300W Power Supply
×1
ESP32 Terminal Block
×1
22 gauge wire
I had this leftover from a past project, and I lost the link!
×1
3 pin wire connectors
×12

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)
Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Schematic

Code

Defining the FastLED array as a big list of all LEDs chained together

Arduino
CRGB *leds;

void setup() {

  leds = new CRGB[NUM_LEDS_TOTAL];

  uint16_t startIndex = 0;
  FastLED.addLeds<NEOPIXEL, PIN_1>(leds, startIndex, NUM_LEDS_PIN_1);
  startIndex += NUM_LEDS_PIN_1;
  FastLED.addLeds<NEOPIXEL, PIN_2>(leds, startIndex, NUM_LEDS_PIN_2);
  startIndex += NUM_LEDS_PIN_2;
  FastLED.addLeds<NEOPIXEL, PIN_3>(leds, startIndex, NUM_LEDS_PIN_3);
  startIndex += NUM_LEDS_PIN_3;
  FastLED.addLeds<NEOPIXEL, PIN_4>(leds, startIndex, NUM_LEDS_PIN_4);
  startIndex += NUM_LEDS_PIN_4;
  FastLED.addLeds<NEOPIXEL, PIN_5>(leds, startIndex, NUM_LEDS_PIN_5);
  startIndex += NUM_LEDS_PIN_5;
  FastLED.addLeds<NEOPIXEL, PIN_6>(leds, startIndex, NUM_LEDS_PIN_6);
  startIndex += NUM_LEDS_PIN_6;
  FastLED.addLeds<NEOPIXEL, PIN_7>(leds, startIndex, NUM_LEDS_PIN_7);

  // ...
}

Defining a simple data structure for the disc info

Arduino
struct Disc {
  uint8_t discIndex;
  uint8_t numLEDs; // number of LEDs in this disc
  uint16_t offset; // number of LEDs in tree before this disc
  CRGB *leds; // the LEDs for this disc
};

Creating Disc instances, while accumulating an offset to track the disc’s position in the whole tree

Arduino
void setup() {
  // ...

  uint16_t offset = 0;
  for (uint8_t d = 0; d < NUM_DISCS; d++) {
    Disc disc = {d, NUM_LEDS_DISC[d], offset, &leds[offset]};
    discs[d] = disc;
    offset += disc.numLEDs;
  }
}

Set each disc to a different color of the rainbow!

Arduino
void loop() {
  for (uint8_t d = 0; d < NUM_DISCS; d++) {
    for (uint8_t p = 0; p < discs[d].numLEDs; p++) {
      discs[d].leds[p] = rainbow[d];
    }
  }
  FastLED.show();
}

Here's the full code on GitHub

Credits

Michelle

Michelle

4 projects • 13 followers
I like learning about programming LEDs for art installations, and creative coding in general. I also love drawing diagrams and soldering.

Comments