WS2812B strips have a tiny controller inside every LED, so one Uno pin can set the colour of hundreds of LEDs. The Adafruit NeoPixel library handles the 800 kHz timing on the Uno with carefully counted assembly code.
The Uno makes the data side easy — its 5 V signal is exactly what the strip expects. Power is the part to get right. A 30-LED strip can pull almost 2 A at full white, far more than USB can give, so the strip gets its own 5 V adapter and only the ground is shared with the Uno.
The sketch first wipes the strip red, one LED at a time, so you can see that every LED responds. Then it runs a smooth rainbow.
Wiring
| Arduino Uno R3 | WS2812B addressable RGB LED strip (NeoPixel) | Wire | Notes |
|---|---|---|---|
| D6 | DIN | green | Via 330 Ω — Resistor close to the first LED. Use the end with the arrow pointing away from the wire. |
| 5 V 2 A adapter · +5V | 5V | red | 1000 µF capacitor across + and − at the strip. A short strip (≤ 8 LEDs, low brightness) can run from the Uno’s 5V pin instead. |
| 5 V 2 A adapter · GND | GND | black | |
| GND | GND | black | Common ground — without it the data signal has no reference and the LEDs flicker randomly. |
5 V (about 60 mA per LED at full white) part, 5 V board. The strip expects a data HIGH of about 3.5 V at 5 V supply. From ESP32 or Pico the 3.3 V signal often works with short wires, but to be safe drive DIN through a 74AHCT125 (or 74HCT125) powered from 5 V.
Board quirks
- The Uno is a 5 V board, so its data signal matches the strip — no level shifter, unlike ESP32 and Pico.
- Each LED can draw 60 mA at full white: 30 LEDs = 1.8 A. The Uno’s USB 5 V gives about 500 mA, so the sketch caps brightness at 50/255 and the strip gets its own adapter.
- Every LED keeps 3 bytes in RAM. 300 LEDs = 900 bytes — nearly half the Uno’s 2 KB — before your own code.
strip.show()turns interrupts off while it sends data (about 30 µs per LED). With long strips,millis()drifts and SoftwareSerial drops characters.
Code
// WS2812B (NeoPixel) strip on an Arduino Uno R3.
// DIN → 330 Ω → D6, 5V and GND from a 5 V supply (shared GND with the Uno).
// Each LED keeps 3 bytes in RAM: 60 LEDs = 180 bytes of the Uno's 2 KB.
#include <Adafruit_NeoPixel.h>
const uint8_t LED_PIN = 6;
const uint16_t LED_COUNT = 30;
const uint8_t BRIGHTNESS = 50; // of 255 - keeps 30 LEDs under about 0.5 A
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(9600);
strip.begin();
strip.setBrightness(BRIGHTNESS);
strip.show(); // all off
Serial.print(F("WS2812B: "));
Serial.print(LED_COUNT);
Serial.println(F(" LEDs on D6"));
}
void loop() {
// One colour wipe as a wiring check, then a rainbow.
static bool wiped = false;
if (!wiped) {
for (uint16_t i = 0; i < LED_COUNT; i++) {
strip.setPixelColor(i, strip.Color(255, 0, 0));
strip.show();
delay(30);
}
Serial.println(F("Red wipe done - every LED should be red"));
wiped = true;
delay(500);
}
static uint16_t hue = 0;
for (uint16_t i = 0; i < LED_COUNT; i++) {
strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(hue + i * 65536UL / LED_COUNT)));
}
strip.show(); // interrupts are off while data is sent (~30 µs per LED)
hue += 256;
delay(20);
}// WS2812B (NeoPixel) strip on an Arduino Uno R3.
// DIN → 330 Ω → D6, 5V and GND from a 5 V supply (shared GND with the Uno).
// Each LED keeps 3 bytes in RAM: 60 LEDs = 180 bytes of the Uno's 2 KB.
#include <Adafruit_NeoPixel.h>
const uint8_t LED_PIN = 6;
const uint16_t LED_COUNT = 30;
const uint8_t BRIGHTNESS = 50; // of 255 - keeps 30 LEDs under about 0.5 A
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(9600);
strip.begin();
strip.setBrightness(BRIGHTNESS);
strip.show(); // all off
Serial.print(F("WS2812B: "));
Serial.print(LED_COUNT);
Serial.println(F(" LEDs on D6"));
}
void loop() {
// One colour wipe as a wiring check, then a rainbow.
static bool wiped = false;
if (!wiped) {
for (uint16_t i = 0; i < LED_COUNT; i++) {
strip.setPixelColor(i, strip.Color(255, 0, 0));
strip.show();
delay(30);
}
Serial.println(F("Red wipe done - every LED should be red"));
wiped = true;
delay(500);
}
static uint16_t hue = 0;
for (uint16_t i = 0; i < LED_COUNT; i++) {
strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(hue + i * 65536UL / LED_COUNT)));
}
strip.show(); // interrupts are off while data is sent (~30 µs per LED)
hue += 256;
delay(20);
}Library: Adafruit NeoPixel (Adafruit) — compiled with Adafruit NeoPixel 1.15.5.
Expected serial output
WS2812B: 30 LEDs on D6
Red wipe done - every LED should be redWS2812B: 30 LEDs on D6 Red wipe done - every LED should be red
Common errors
Nothing lights at all
You are feeding the DOUT end. Data must enter at DIN — follow the arrows printed on the strip. Also check the common GND.
Random colours and flicker
Missing common GND between the adapter and the Uno, or no 330 Ω resistor on a long data wire.
Colours swapped (red shows as green)
Some strips are RGB, not GRB. Change NEO_GRB to NEO_RGB.
The end of the strip turns yellow or orange
Voltage drop along the strip. Feed 5 V and GND into both ends for strips over about 1 m.