🛠 Bandeau NeoPixel piloté par le périphérique RMT

ESP32-C3 · intermediaire · Schéma : IMG-esp32-c3-intermediaire-1-neopixel-rmt-gpio.svg — Bandeau de 8 LED WS2812 alimenté en 5 V, données sur GPIO7 du ESP32-C3 via le périphérique RMT, masses communes reliées

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

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

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials