Built-in project · Arduino Uno R3

Marigold path on an Arduino Uno

A WS2812B strip glows like a path of marigold petals for Día de los Muertos, with a wave of gold traveling from the door to four LEDs breathing orange at the ofrenda. The whole build, an Arduino Uno and 5 more parts, runs here in your browser on the firmware below; open it in the editor to change the wiring or the code and run it again.

Teaching? Assign it to your class in one click.

Beginner Runs in your browser. Free, and no account needed.

Marigold path · Arduino Uno R3live0.000 s 0.00x
Click to open it in the editor
The circuit itself, running here on the simulator. Press what can be pressed; click anything else to open it in the editor.

The code

The firmware exactly as the editor opens it. Change a line there and press Run: it compiles in the browser.

sketch.ino · Arduino Uno R3
// Marigold path: a strip of LEDs laid along the floor like a path of marigold
// petals, with a glow of orange and gold that travels from the door to the
// ofrenda, where a cluster of marigold lights glows warm.
//
//   path      16 WS2812B LEDs, DIN <- 330 ohms <- pin 6 (LED 0 at the door)
//   altar     4 WS2812B LEDs, DIN <- 330 ohms <- pin 5
//   knob      potentiometer wiper -> A0, ends to 5 V and GND: the pace
//
// For Día de los Muertos, families scatter petals of cempasúchil, the Mexican
// marigold, in a path from the front door to the ofrenda. Their bright color
// and scent are said to guide the spirits home.
//
// The path glows a soft marigold all along, and a brighter wave of gold
// travels slowly from the door toward the altar, again and again. The altar's
// four LEDs breathe in deep orange. Every LED's color is a mix of red and a
// little less green: that is the whole range from orange to gold.
//
// Things to try. Turn the knob to slow the wave. Make the wave longer with
// WAVE. Lay the strip in a curve around the room.

#include <Adafruit_NeoPixel.h>

const int PATH = 16, ALTAR = 4;
const int WAVE = 4;   // how many LEDs the bright wave covers

Adafruit_NeoPixel path(PATH, 6, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel altar(ALTAR, 5, NEO_GRB + NEO_KHZ800);

int head = 0;   // in 1/8ths of an LED
unsigned long frames = 0;

void setup() {
  Serial.begin(9600);
  path.begin();
  altar.begin();
  path.setBrightness(160);
  altar.setBrightness(200);
  Serial.println("The marigold path is glowing");
}

void loop() {
  int pace = map(analogRead(A0), 0, 1023, 1, 6);
  head += pace;
  if (head >= (PATH + WAVE) * 8) {
    head = 0;
    Serial.println("The glow reached the ofrenda");
  }

  for (int i = 0; i < PATH; i++) {
    int r = 120, g = 45;   // the resting marigold
    int d = head / 8 - i;  // how far behind the wave's front
    if (d >= 0 && d < WAVE) {
      r = 255;
      g = 150 - d * 25;    // gold at the front, orange behind
    }
    path.setPixelColor(i, r, g, 0);
  }

  // The altar breathes slowly between deep orange and gold.
  int t = (frames * 3) % 512;
  int glow = t < 256 ? t : 511 - t;
  for (int i = 0; i < ALTAR; i++) altar.setPixelColor(i, 200 + glow / 5, 60 + glow / 4, 0);

  path.show();
  altar.show();
  frames++;
  delay(25);
}

Parts list

7 parts, plus the jumper wires. Every one is in the editor's parts bin.

How it is wired

7 connections, pin by pin, read from the circuit itself. Each line is one set of pins joined together, by a jumper wire or a breadboard strip.

  • Arduino Uno R3 pin 6; Resistor, 330 Ω (1) pin 1
  • Arduino Uno R3 pin 5; Resistor, 330 Ω (2) pin 1
  • Arduino Uno R3 pin 5V; Potentiometer pin 3; Addressable RGB LEDs (1) pin VDD; Addressable RGB LEDs (2) pin VDD
  • Ground: Arduino Uno R3 pin GND; Potentiometer pin 1; Addressable RGB LEDs (1) pin VSS; Addressable RGB LEDs (2) pin VSS
  • Arduino Uno R3 pin A0; Potentiometer pin 2
  • Resistor, 330 Ω (1) pin 2; Addressable RGB LEDs (1) pin DIN
  • Resistor, 330 Ω (2) pin 2; Addressable RGB LEDs (2) pin DIN

Change it and keep it

Open it in the editor, change the circuit or the code, and keep your version in a free account.