🛠 Bandeau NeoPixel piloté par le périphérique RMT
Objectives
Control WS2812 (NeoPixel) addressable LEDs with the ESP32-C3. The Adafruit_NeoPixel library uses the RMT (Remote Control) peripheral on the C3 to generate timing slots with quarter-microsecond precision, without monopolizing the CPU. Avoid the strapping pins (GPIO2, 8, 9) by choosing GPIO7 for the data line.
Hardware
- 1 ESP32-C3 board
- 1 strip of 8 WS2812B LEDs (separate 5 V power supply recommended)
- 1 330 Ω resistor on the data line + 1000 µF capacitor on the power supply
- Adafruit NeoPixel library (Library Manager)
Complete code
#include <Adafruit_NeoPixel.h>
#define PIN_NEO 7 // evite GPIO2/8/9 (strapping) et GPIO9 (BOOT)
#define N 8
Adafruit_NeoPixel strip(N, PIN_NEO, NEO_GRB + NEO_KHZ800);
uint32_t i = 0;
void setup {
strip.begin;
strip.setBrightness(40); // menage l'alimentation
strip.show;
}
void loop {
for (uint16_t b = 0; b < N; b++) strip.setPixelColor(b, 0, 0, 0);
strip.setPixelColor(i % N, strip.Color(255, 60, 0)); // balle orange
strip.show;
i++;
delay(120);
}
Expected verification
An orange LED travels along the strip in a loop. The ESP32-C3 has only one core and runs the Wi-Fi stack in parallel: the RMT generates WS2812 frames without the animation stuttering.
Common errors
- 5 V on the strip's data pin towards the C3: some strips accept 5 V on the data input, but starting from a 3.3 V GPIO remains the standard; never reverse VCC and GND.
- Non-common grounds between the 5 V power supply and the board: LEDs blinking randomly.
- Inverted color order (GRB vs RGB): displayed colors do not match the sent values.
- Data placed on GPIO8: the strip's internal pull-down at rest pulls the strapping pin low and may prevent booting.
Other tutorials for this board
Code examples for this board
clignotante.inoArduinobouton-led.inoArduinorespiration.inoArduinodht22.inoArduinooled-i2c.inoArduinoserveur-web.inoArduino