Breadboard
docs
Example project · Displays

NeoPixel ring rainbow

An ESP32-C3 running real MicroPython chases a rainbow around a 12-pixel WS2812 ring — the genuine 800 kHz protocol, decoded with cycle accuracy. Edit the colors in the Code tab.

The NeoPixel ring rainbow circuit as rendered by the simulator

What's on the bench

  • Battery
  • ESP32-C3
  • NeoPixel ring ×12

How it's wired

  • hole a10hole B-5
  • hole a11hole B+5
  • hole a40hole B+9
  • hole a42hole B-9
  • hole a14hole c41

The code

This MicroPython script runs on the emulated board every boot; edit it in the Code tab.

# Rainbow chase around the 12-pixel ring (DIN on G2).
import machine, neopixel, time

RAINBOW = [
    (255, 0, 0), (255, 96, 0), (255, 200, 0), (96, 255, 0),
    (0, 255, 60), (0, 255, 200), (0, 160, 255), (0, 40, 255),
    (90, 0, 255), (200, 0, 255), (255, 0, 160), (255, 0, 60),
]
np = neopixel.NeoPixel(machine.Pin(2), 12)
for step in range(600):
    for i in range(12):
        np[i] = RAINBOW[(i + step) % 12]
    np.write()
    time.sleep_ms(120)
print('ring demo done')

Related projects