🛠 Faire clignoter une LED avec l'ESP32-S2

ESP32-S2 · debutant · Schéma : IMG-esp32-s2-debutant-1-esp32-s2-clignotement-led.svg — Carte ESP32-S2, broche GPIO2 reliée via une résistance de 330 Ω à une LED dont la cathode va au GND.

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

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

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials