Wiring guide

How to wire a WS2812 LED strip to an Arduino Uno R4

To wire a WS2812 LED strip to an Arduino Uno R4, connect VDD to 5V, VSS to GND and DIN to pin 2. The Arduino Uno R4 is a 5 V board, so the strip’s power and data line are both 5 V and nothing needs shifting. The sketch below uses the Adafruit NeoPixel (Adafruit_NeoPixel.h) library. It runs a moving rainbow across eight pixels.

  • 5 V logic
  • Library: Adafruit_NeoPixel.h
  • 3 wires
Arduino Uno R4 · WS2812 LED striplive0.000 s 0.00x
Click to open it in the editor
The circuit itself, running on the simulator with the sketch below. Press what can be pressed; click anything else to open it in the editor.
Pin to pin

WS2812 LED strip to Arduino Uno R4 wiring table

Every wire in the circuit above, with the part’s pin names and the board’s own labels. The wire colors are the ones the circuit uses; on a real bench any colors work.

WS2812 LED strip pinArduino Uno R4 pinWire colorWhy
VDD (5V)5VredWS2812B pixels are 5 V parts; each can draw up to 60 mA at full white.
VSS (GND)GNDblueCommon ground, or the data line has no reference.
DINpin 2greenThe data line into the first pixel. Each pixel keeps 24 bits and passes the rest on.
Voltage

Power and logic levels for WS2812 LED strip and Arduino Uno R4

Logic level

The Arduino Uno R4’s pins are 5 V logic. A 5 V part can drive them directly; a part whose signal pins are limited to 3.3 V needs a level shifter.

Supply

The WS2812 LED strip takes 5 V from 5V. That is the Arduino Uno R4’s 5 V rail, so the part shares the current the board can supply.

This pair

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

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.

The sketch

The working code for the Arduino Uno R4

Library: Adafruit NeoPixel (Adafruit_NeoPixel.h). This is the sketch the circuit above runs.

NeoPixel rainbow on Arduino Uno R4 pin 2
#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);
}
Output

What you should see

Eight pixels show a rainbow that slides along the strip, a little further every 20 ms, at low brightness. The serial monitor, at 9600 baud, prints Rainbow once.

If one color is wrong, the pixels are wired in a different order from the sketch: the strip type NEO_GRB covers most WS2812B strips.

The serial monitor prints this, recorded from the circuit above running:

Rainbow
Pitfalls

Common mistakes wiring a WS2812 LED strip to an 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.

Build your own WS2812 LED strip project

Open this circuit in the editor, change the wiring or the code, and keep your version in a free account.