How to wire a WS2812 LED strip to a Raspberry Pi Pico
To wire a WS2812 LED strip to a Raspberry Pi Pico, connect VDD to VBUS (5 V from USB), VSS to GND and DIN to GP15 (physical pin 20). The strip is a 5 V part and its data line comes from a 3.3 V pin, which works on many strips and flickers on others, so use a level shifter on DIN for anything permanent. The sketch below uses the Adafruit NeoPixel (Adafruit_NeoPixel.h) library. It runs a moving rainbow across eight pixels.
- 3.3 V logic
- Library: Adafruit_NeoPixel.h
- 3 wires
WS2812 LED strip to Raspberry Pi Pico 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 pin | Raspberry Pi Pico pin | Wire color | Why |
|---|---|---|---|
| VDD (5V) | VBUS (5 V from USB) | red | WS2812B pixels are 5 V parts; each can draw up to 60 mA at full white. |
| VSS (GND) | GND | blue | Common ground, or the data line has no reference. |
| DIN | GP15 (physical pin 20) | green | The data line into the first pixel. Each pixel keeps 24 bits and passes the rest on. |
Power and logic levels for WS2812 LED strip and Raspberry Pi Pico
Logic level
The Raspberry Pi Pico’s GPIO pins are 3.3 V logic and are not 5 V tolerant. Nothing wired to a pin may go above 3.3 V.
Supply
The WS2812 LED strip takes 5 V from VBUS (5 V from USB). That is the Raspberry Pi Pico’s 5 V rail, so the part shares the current the board can supply.
This pair
The strip runs from VBUS (5 V from USB) while DIN comes from a 3.3 V pin. A WS2812B wants about 0.7 times its supply, 3.5 V, to see a high, so on a real bench a 3.3 V signal works on some strips and flickers on others. A 74AHCT125 level shifter on DIN fixes it for good. Add a 330 ohm resistor in series with DIN and a 1000 uF capacitor across the supply on any strip longer than a few pixels.
Pins to leave alone
The numbers in the code are GP numbers, not the physical pin numbers printed beside the header: GP15 is pin 20. GP23 to GP25 are used on the board itself, and GP25 is the LED.
The working code for the Raspberry Pi Pico
Library: Adafruit NeoPixel (Adafruit_NeoPixel.h). This is the sketch the circuit above runs.
#include <Adafruit_NeoPixel.h>
const int PIXEL_PIN = 15; // DIN, GP15 (physical pin 20)
const int PIXELS = 8;
Adafruit_NeoPixel strip(PIXELS, PIXEL_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(115200);
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);
}
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 115200 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:
RainbowCommon mistakes wiring a WS2812 LED strip to a Raspberry Pi Pico
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.
Expecting 3.3 V data to always work
It works on the simulated strip and on many real ones. When a real strip flickers or shows random colors on the first pixel, the 3.3 V data line is the first suspect: add a 74AHCT125 level shifter.
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.