🛠 Faire clignoter une LED avec l'ESP32-S2
Objectives
Discover digital output on the ESP32-S2: configure a GPIO pin as an output, set it to high then low, and insert delays to achieve regular blinking.
Hardware
- ESP32-S2 development board (DevKitM-1 type)
- 1 red LED (or the onboard LED if your board has one)
- 1 330 Ω resistor
- 2 Dupont cables and a breadboard
Complete code
// Clignotement LED sur ESP32-S2
const uint8_t LED_PIN = 2;
void setup {
pinMode(LED_PIN, OUTPUT);
}
void loop {
digitalWrite(LED_PIN, HIGH); // LED allumée
delay(500);
digitalWrite(LED_PIN, LOW); // LED éteinte
delay(500);
}
Expected verification
Upon upload, the LED blinks once per second: 500 ms on, 500 ms off. Modify the value of delay to change the speed and confirm that the rhythm follows.
Common errors
- Wrong pin: the onboard LED on some S2 boards is not on GPIO2; check your board's schematic.
- Missing resistor: the LED may shine too brightly or degrade.
- Anode/cathode inversion: the long leg (anode) goes to the resistor, the short leg to GND.
- Wrong serial port selected in the IDE: the ESP32-S2 is available via both UART and native USB, test both ports.
Other tutorials for this board
Code examples for this board
clignotante.inoArduinobouton-led.inoArduinorespiration.inoArduinodht22.inoArduinooled-i2c.inoArduinoserveur-web.inoArduino