Part

Addressable RGB LEDs

RGB LEDs on one wire, as a strip or a 16 wide panel.

or see every part
  • 4 pins
  • 3 properties
Drawn live by the editor's own code, at the size you see it.
Reference

Every one of its 4 pins

Pin
Role
What it does
VDD
Input or output
Supply.
VSS
Input or output
Ground.
DIN
Input
The pulse-coded data line in.
DOUT
Output
Whatever is left of the frame after this device's own LEDs, for chaining.
This part

What it does

WS2812B LEDs, sold as NeoPixels, put a red, green and blue LED and a small controller in every pixel and chain them all on one data wire. There is no clock: each bit is a high pulse whose length is the bit, about 0.4 microseconds for a nought and 0.8 for a one, twenty-four bits a pixel, green first, and fifty microseconds of quiet makes every LED take up its new color at once. Mokxi’s part decodes those pulses from the pin’s own edges inside the datasheet’s timing windows, and abandons a frame it cannot read the way a real strip does. The same part is a strip, a ring or a matrix, up to 1024 LEDs. Because the timing needs a fast core, the WS2812 driver and the Adafruit_NeoPixel calls run on the ESP32-C3 and ESP32-C6 here. Power draw is not modeled, so a long strip never browns out a board.

How to use it

How to use WS2812B NeoPixels with an ESP32

DIN to a GPIO, VDD to 5 V, VSS to GND, and a ground shared with the board. The Adafruit_NeoPixel calls compile as they stand: create the strip with its length and pin, set colors with setPixelColor(), and call show() to send them. Keep the brightness down on a real strip, because each pixel can draw up to 60 milliamps at full white.

On a real Arduino Uno the Adafruit library drives WS2812s with hand-timed assembly. In Mokxi the WS2812 driver needs a faster core, so it runs on the ESP32-C3 and ESP32-C6.

Part pin
Board pin
DIN
GPIO 5
VDD
5 V
VSS
GND
ESP32-C3: WS2812B rainbowlive0.000 s 0.00x
Click to open it in the editor
This is the simulator itself, running here. Click anything to open it in the editor.
One green pixel
#include <Adafruit_NeoPixel.h>

Adafruit_NeoPixel pixels(8, 4, NEO_GRB + NEO_KHZ800);

void setup() {
  pixels.begin();
  pixels.setPixelColor(0, pixels.Color(0, 150, 0));
  pixels.show();
}

void loop() {}
Reference

The 3 properties you can set

Property
Default
What it means
count
8
how many LEDs.
layout
strip (or ring, matrix)
strip, ring or matrix.
serpentine
false
whether a matrix is wired boustrophedon (every other row reversed), which the wiring decides and the data alone cannot say.
How it is modeled

What is true about the Addressable RGB LEDs, here

What is modeled

layout = "ring" bends the same row of LEDs into a circle, LED 0 at twelve o'clock and the rest clockwise, exactly how the rings people buy are numbered. A ring is a strip electrically, so nothing about the wiring or the firmware changes, only the picture does. Nothing is shown until the latch: 50 microseconds of a quiet line ends the frame, and every LED takes up its new color at once, the way a real strip does.

Not modeled

No brightness curve beyond a straight RGB value, and no power draw per LED, so a strip here never browns out a board's supply the way a long real one can.

The decode is the datasheet's windows. A high pulse under 125 ns is a glitch and is ignored; from there to 600 ns is a nought and from 600 ns to 950 ns is a one, 950 ns being T1H at the top of its ±150 ns tolerance. The low between bits is checked too (at least 300 ns after a one and 700 ns after a nought, both the bottom of their tolerances), and a stream that breaks either rule abandons the frame, the way a real strip stops following one it cannot read. The total bit period is not checked on top of that: the datasheet's own figure is 1.25 us ±600 ns, which constrains nothing once both halves are, and real strips take faster streams than 1.25 us happily. The 300 ns of forward delay per device is modeled as a flat 150 ns.

The latch is 50 microseconds of quiet, which is the original WS2812B figure; a WS2812B-V5 wants 280 microseconds, so a driver written against this one can produce a frame that never latches on newer strips. The color order is fixed at GRB (there is no RGBW and no way to say a strip is wired otherwise), and there is no per-LED refresh, no gamma, no thermal limit and no maximum of anything except the 1024 LEDs one part will hold.

From WS2812 addressable LEDs, in full.

Projects

See the Addressable RGB LEDs in a project

Shown here on: ESP32-C3-DevKitM-1, ESP32-C6-DevKitC-1

Learn

Where it turns up in a lesson

In a learn article

Wire up the Addressable RGB LEDs

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.