Arduino Uno NeoPixel Simulator: Wiring, Code and a Live Circuit
This is a strip of eight WS2812B NeoPixels wired to an Arduino Uno, running a rainbow live in your browser with the Adafruit NeoPixel library. Each pixel on the drawing shows the color the board sent it.
Three wires: 5 V, ground, and DIN to pin 6. The Arduino Uno is a 5 V board, so the data line needs no level shifter.
- 5 V logic
- Library: Adafruit_NeoPixel.h
- DIN on pin 6
- 8 pixels, brightness 40
Wiring the NeoPixel to the Arduino Uno
Every connection in the circuit above, with the board’s own pin names.
| NeoPixel pin | Arduino Uno pin | Why |
|---|---|---|
| VDD (5V) | 5V | WS2812B pixels are 5 V parts; each can draw up to 60 mA at full white. |
| VSS (GND) | GND | Common ground, or the data line has no reference. |
| DIN | pin 6 | The data line into the first pixel. Each pixel keeps 24 bits and passes the rest on. |
The Arduino Uno drives DIN at 5 V, which is exactly what the pixels expect. Eight pixels at brightness 40 are well within what USB gives; a longer strip at full white needs its own 5 V supply, a 330 ohm resistor in series with DIN and a 1000 uF capacitor across the supply.
Pins to leave alone on the Arduino Uno
Pins 0 and 1 are the USB serial port on a real Uno, so anything wired there fights the upload and the serial monitor. Pin 13 carries the onboard LED.
On a real bench
On a real bench the Uno stands beside the breadboard: the NeoPixel goes into the breadboard and male-to-male jumpers run from the Uno’s female headers to its rows. Power the Uno from USB while you build, and unplug it before you move a wire.
The code
The sketch the circuit above runs. Open it in the editor, change a line and press Run: it compiles in your browser.
#include <Adafruit_NeoPixel.h>
const int PIXEL_PIN = 6; // DIN, pin 6
const int PIXELS = 8;
Adafruit_NeoPixel strip(PIXELS, PIXEL_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(9600);
strip.begin();
strip.setBrightness(40); // of 255: easy on the eyes and on the supply
strip.show(); // all off
Serial.println("Rainbow");
}
void loop() {
static uint16_t hue = 0;
for (int i = 0; i < PIXELS; i++) {
uint16_t h = hue + i * (65536L / PIXELS);
strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(h)));
}
strip.show();
hue += 512;
delay(20);
}
Adafruit_NeoPixel strip(PIXELS, PIXEL_PIN, NEO_GRB + NEO_KHZ800) describes eight WS2812B pixels on pin 6, which take their colors green first at 800 kHz. On the ATmega328P the library sends each bit with counted instructions, interrupts off, exactly as the real library does.
ColorHSV() turns a hue from 0 to 65535 into red, green and blue, and gamma32() corrects it for how the eye sees brightness. Each pixel is offset by an eighth of the color wheel, so the eight make a full rainbow.
setPixelColor() only changes the library’s buffer; show() sends all 24 bits per pixel down the line at once. setBrightness(40) scales everything to about a sixth, which is also a sixth of the current.
Common mistakes with the NeoPixel on the Arduino Uno
Forgetting show()
setPixelColor() writes to memory only. Nothing changes on the strip until show() sends the buffer, so a sketch without it leaves every pixel dark.
Wiring the wrong end
Data flows one way. DIN is the input end, marked with an arrow on most strips; wired to DOUT at the far end, nothing lights. In the editor the part’s DIN pin is the one on the left.
Running a long strip from the board
Sixty pixels at full white can draw 3.6 A, far beyond the 5V pin. Power the strip directly from a 5 V supply, join the grounds, and keep the brightness down in code.
Questions and answers
Can I simulate NeoPixels with an Arduino Uno?
Yes. The circuit at the top of this page is an Arduino Uno with a WS2812B strip, running in your browser on a simulated ATmega328P. The simulated pixels decode the real 800 kHz bit stream from the pin, so a timing or color-order mistake shows up as it would on a desk. Press Run it in the editor to change the wiring or the code; it is free and needs no account.
Does FastLED work too?
Yes, FastLED.h compiles and runs on an Arduino Uno in the simulator. Use FastLED.addLeds<WS2812B, 6, GRB>(leds, 8) and FastLED.show().
Why are my colors wrong?
Most WS2812B strips take green first, which is what NEO_GRB says. A strip whose red and green are swapped is an RGB one: change NEO_GRB to NEO_RGB.
Which boards can drive NeoPixels in this simulator?
The AVR boards (Uno, Nano, Mega), the ESP32-C3 and the ESP32-C6. On the other boards the WS2812B bit is too short for the simulated core to time by hand, and the library stops at compile time with a message saying so.
Build your own NeoPixel project
Open this circuit in the editor, change the wiring or the code, and keep your version in a free account.