Preview build — page text is a draft awaiting human review. Code badges come from real compiles. The flasher is real but not yet hardware-tested; the Playground is still a preview.

WS2812B (NeoPixel) LED strip with ESP32 — wiring and rainbow code

Drive a short WS2812B strip from an ESP32 DevKit V1 on GPIO13 with a 330 Ω series resistor, safe power limits and the Adafruit NeoPixel library.

Arduino C++Verified — core esp32 3.3.12, Adafruit NeoPixel 1.15.5, 3 Nov 2026Compile-only

Community draft — report a mistake

WS2812B strips put a tiny controller inside every LED, so one GPIO drives the whole strip. The ESP32 handles the 800 kHz timing in hardware.

Two things matter on an ESP32: power (each LED can draw 60 mA, so anything beyond a short strip needs its own 5 V supply with a shared ground) and logic level (the strip is 5 V, the ESP32 is 3.3 V — usually fine on short wires, with a buffer as the fix if not).

Wiring

ESP32 DevKit V1Only the pins used are shown · 3.3 V logicWS2812B addressable RGB LED strip (NeoPixel)330 ΩD13GNDVINDIN5VGNDDOUT (not connected)
Also needed: 330 Ω resistor, 1000 µF capacitor for strips on their own supply.
Every connection
ESP32 DevKit V1WS2812B addressable RGB LED strip (NeoPixel)WireNotes
D13DINgreenVia 330 Ω — Series resistor close to the first LED protects its input.
VIN5VredAbout 8 LEDs at low brightness from USB. Longer strips: separate 5 V supply, 1000 µF capacitor across it, common GND.
GNDGNDblack

5 V (about 60 mA per LED at full white) part, 3.3 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 strip runs at 5 V and expects at least about 3.5 V for a logic HIGH; the ESP32’s 3.3 V usually works on short wires. If the first LED flickers, add a 74AHCT125 buffer powered from 5 V.
  • Brightness is capped at 40/255 so 8 LEDs stay well under 500 mA — full white is about 60 mA per LED.
  • The ESP32 core sends NeoPixel data with the RMT peripheral, so Wi-Fi doesn’t disturb the timing.

Code

ws2812b-esp32.inoArduino C++Open in PlaygroundOpen in PlaygroundFlash
// WS2812B LED strip (8 LEDs) on an ESP32 DevKit V1.
// DIN → D13 through a 330 Ω resistor, strip 5V → VIN (short strip only), GND → GND.
#include <Adafruit_NeoPixel.h>

constexpr uint8_t LED_PIN = 13;
constexpr uint16_t LED_COUNT = 8;

Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  Serial.begin(115200);
  strip.begin();
  strip.setBrightness(40);  // keeps current low on USB power (~20 mA per LED at this level)
  strip.show();
  Serial.println("WS2812B rainbow on GPIO13");
}

void loop() {
  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();
  hue += 256;
  delay(20);
}

Library: Adafruit NeoPixel (Adafruit) — compiled with Adafruit NeoPixel 1.15.5.

Expected serial output

Serial Monitor · 115200Output
WS2812B rainbow on GPIO13

Common errors

First LED wrong colour, rest fine

Marginal 3.3 V data. Shorten the data wire, keep the 330 Ω resistor, or add a 74AHCT125 level buffer.

Colours swapped (red shows green)

Some strips are RGB, not GRB. Change NEO_GRB to NEO_RGB.

↑↓ to move · Enter to open