🛠 Faire clignoter la LED RGB sur GPIO8
Objectives
First hello-world for the ESP32-C3 (RISC-V, single core, Wi-Fi + Bluetooth 5): control the onboard RGB LED on GPIO8, present on most compact boards (SuperMini, DevKitM). You will also learn about the peculiarity of this pin: GPIO8 is a strapping pin, which imposes wiring precautions.
Hardware
- 1 ESP32-C3 board (SuperMini or DevKitM-1, 4 MB flash)
- 1 USB-C data cable
- No external components if the LED is onboard
Complete code
const uint8_t LED = 8; // LED RGB embarquee, aussi broche de strapping
void setup {
pinMode(LED, OUTPUT);
}
void loop {
digitalWrite(LED, HIGH); delay(150); // double flash
digitalWrite(LED, LOW); delay(150);
digitalWrite(LED, HIGH); delay(150);
digitalWrite(LED, LOW); delay(850); // pause
}
Expected verification
The LED blinks according to a pattern of two short flashes followed by a one-second pause. By selecting the "ESP32C3 Dev Module" board in the Tools menu, flashing goes directly through USB-C without needing to hold a button on most boards.
Common errors
- Wrong board type: choose an "ESP32C3…" board, not "ESP32 Dev Module" (Xtensa architecture), otherwise the binary will not start.
- Charge-only USB-C cable: the serial port never appears; test with another cable.
- Connecting GPIO8 to ground via a permanent resistor: GPIO8 is a strapping pin (along with GPIO2 and GPIO9) and must be able to remain at a high level at startup, otherwise booting will be erratic.
- Board without an LED on GPIO8: check your board's schematic, some place the LED on GPIO12 or a WS2812 LED on GPIO8.
Other tutorials for this board
Code examples for this board
clignotante.inoArduinobouton-led.inoArduinorespiration.inoArduinodht22.inoArduinooled-i2c.inoArduinoserveur-web.inoArduino