Arduino Uno R4 NeoPixel Simulator: Wiring, Code and a Live Circuit
This is a strip of eight WS2812B NeoPixels wired to an Arduino Uno R4 Minima, 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 2. The Arduino Uno R4 is a 5 V board, so the data line needs no level shifter.
- 5 V logic
- Library: Adafruit_NeoPixel.h
- DIN on pin 2
- 8 pixels, brightness 40
Wiring the NeoPixel to the Arduino Uno R4
Every connection in the circuit above, with the board’s own pin names.
| NeoPixel pin | Arduino Uno R4 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 2 | The data line into the first pixel. Each pixel keeps 24 bits and passes the rest on. |
The Arduino Uno R4 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 R4
An Uno sketch’s source builds for the R4, but a compiled Uno program will not run on it: different chip. The R4’s pins source less current than an Uno’s, about 8 mA each, so do not drive a relay coil or a motor straight from one.
On a real bench
The Uno R4 Minima fits every Uno shield and every Uno breadboard layout, so wire the NeoPixel exactly as you would on an Uno R3. It has a USB-C socket, and its VIN accepts up to 24 V where an Uno R3 stops at 12.
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 = 2; // DIN, pin 2
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 2, which take their colors green first at 800 kHz. On the ESP32-C3 the library times each bit on the RISC-V core.
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 R4
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 R4 Minima?
Yes. The circuit at the top of this page is an Arduino Uno R4 Minima with a WS2812B strip, running in your browser on a simulated Renesas RA4M1 (Cortex-M4). 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 R4 Minima in the simulator. Use FastLED.addLeds<WS2812B, 2, 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.