The ESP32-C6-DevKitC-1 comes with one addressable LED on board, which makes it a good place to learn NeoPixel code. This guide adds a real strip on GPIO10 with its own 5 V adapter and a common ground.
The sketch runs a rainbow along the strip and shows the first pixel’s colour, dimmed, on the board’s own LED.
Wiring
| ESP32-C6-DevKitC-1 | WS2812B addressable RGB LED strip (NeoPixel) | Wire | Notes |
|---|---|---|---|
| 10 | DIN | green | Via 330 Ω |
| 5 V 2 A adapter · +5V | 5V | red | 1000 µF capacitor across 5V/GND at the strip. |
| 5 V 2 A adapter · GND | GND | black | |
| GND | GND | black | Common ground with the DevKitC. |
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 DevKitC-1 already has a WS2812 on GPIO8.
RGB_BUILTINpoints at it, andrgbLedWrite()drives it without any library. - The C6 has only two RMT transmit channels. The strip and the on-board LED use one each, so a third LED output would need another method.
- Don’t put the strip on GPIO8 itself (strapping pin, already used by the LED) or on GPIO12/13 (USB).
Code
// WS2812B strip on an ESP32-C6-DevKitC-1, plus the board's own RGB LED on GPIO8.
// DIN → GPIO10 through 330 Ω. Strip 5V/GND → its own 5 V supply; supply GND → board GND.
#include <Adafruit_NeoPixel.h>
constexpr uint8_t STRIP_PIN = 10;
constexpr uint16_t COUNT = 30;
Adafruit_NeoPixel strip(COUNT, STRIP_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(115200);
strip.begin();
strip.setBrightness(60);
strip.show();
Serial.printf("WS2812B: %u LEDs on GPIO10, on-board LED on GPIO8\n", COUNT);
}
void loop() {
static uint16_t hue = 0;
for (uint16_t i = 0; i < COUNT; i++) {
strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(hue + i * 65536UL / COUNT)));
}
strip.show();
// The on-board LED follows the colour of the first pixel, dimmed.
uint32_t c = strip.gamma32(strip.ColorHSV(hue));
rgbLedWrite(RGB_BUILTIN, (c >> 16 & 0xFF) / 8, (c >> 8 & 0xFF) / 8, (c & 0xFF) / 8);
hue += 256;
delay(20);
}// WS2812B strip on an ESP32-C6-DevKitC-1, plus the board's own RGB LED on GPIO8.
// DIN → GPIO10 through 330 Ω. Strip 5V/GND → its own 5 V supply; supply GND → board GND.
#include <Adafruit_NeoPixel.h>
constexpr uint8_t STRIP_PIN = 10;
constexpr uint16_t COUNT = 30;
Adafruit_NeoPixel strip(COUNT, STRIP_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(115200);
strip.begin();
strip.setBrightness(60);
strip.show();
Serial.printf("WS2812B: %u LEDs on GPIO10, on-board LED on GPIO8\n", COUNT);
}
void loop() {
static uint16_t hue = 0;
for (uint16_t i = 0; i < COUNT; i++) {
strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(hue + i * 65536UL / COUNT)));
}
strip.show();
// The on-board LED follows the colour of the first pixel, dimmed.
uint32_t c = strip.gamma32(strip.ColorHSV(hue));
rgbLedWrite(RGB_BUILTIN, (c >> 16 & 0xFF) / 8, (c >> 8 & 0xFF) / 8, (c & 0xFF) / 8);
hue += 256;
delay(20);
}Library: Adafruit NeoPixel (Adafruit) — compiled with Adafruit NeoPixel 1.15.5.
Expected serial output
WS2812B: 30 LEDs on GPIO10, on-board LED on GPIO8WS2812B: 30 LEDs on GPIO10, on-board LED on GPIO8
Common errors
Strip dark, on-board LED works
Missing common GND, or data into DOUT instead of DIN.
Colours flicker on the first LED
3.3 V data is marginal for 5 V LEDs. Shorten the data wire or add a 74AHCT125 buffer.