🛠 Faire clignoter la LED RGB native sur GPIO48
Objectives
Discover the ESP32-S3 (dual-core Xtensa LX7 up to 240 MHz, Wi-Fi 2.4 GHz + Bluetooth 5 LE) with your first program: controlling the addressable WS2812 RGB LED that most boards embed on GPIO48 (DevKitC-1 v1.1, Seeed XIAO ESP32S3, LILYGO T-Display-S3). You will learn how to install the Espressif core in the Arduino IDE, how to choose the correct board type, and why an "RGB" LED on paper is actually an addressable LED controlled by a serial protocol, rather than by three pins.
Hardware
- 1 ESP32-S3 board (DevKitC-1 v1.1, XIAO ESP32S3 or T-Display-S3, minimum 8 MB flash)
- 1 USB data cable (USB-C or micro-USB depending on the board)
- No external components: the WS2812 is soldered onto the board
Complete Code
// WS2812 embarque sur GPIO48 (DevKitC-1 v1.1, XIAO, T-Display-S3)
#include <Adafruit_NeoPixel.h>
#define LED_PIN 48
#define N_LED 1
Adafruit_NeoPixel px(N_LED, LED_PIN, NEO_GRB + NEO_KHZ800);
void setup {
px.begin;
px.setBrightness(40); // limiter le courant dans le pixel
}
void loop {
static uint32_t c = 0;
c += 0x10101; // rampe lente de couleur
px.setPixelColor(0, c);
px.show; // trame RMT vers la LED
delay(50);
}
Expected Verification
After uploading (board type "ESP32S3 Dev Module", USB CDC enabled), the embedded pixel continuously cycles through a smooth color ramp. No wiring is necessary: the WS2812 chip is already powered at 3.3 V and connected to GPIO48. If your board has multiple pixels (some T-Display models), change N_LED to 2 or 3.
Common Errors
- Confusing it with a three-pin RGB LED: the WS2812 is an addressable LED that receives data frames on a single pin; a simple digitalWrite will not produce any meaningful result.
- Wrong GPIO: on the S3 it is GPIO48, not GPIO2 as on the classic ESP32; check the schematic of YOUR board.
- Forgetting the library: install "Adafruit NeoPixel" via the Arduino IDE library manager.
- Wrong board type: choose an "ESP32S3..." board, not "ESP32 Dev Module" (classic Xtensa), otherwise the binary may not start.
- Charge-only USB cable: the serial port does not appear in the IDE; try another cable.
Other tutorials for this board
Code examples for this board
clignotante.inoArduinobouton-led.inoArduinorespiration.inoArduinodht22.inoArduinooled-i2c.inoArduinoserveur-web.inoArduino