clignotante.ino
The board's sanity check: the LED blinks at 1 Hz using millis() instead of delay(), leaving the loop free for Wi-Fi or sensors. The monitor also prints free heap — handy before adding radio libraries.
Hardware required
A classic ESP32 board (ESP32-WROOM-32 module, dual-core Xtensa 240 MHz, Wi-Fi + Bluetooth) such as a DevKitC / DOIT V1, powered over micro-USB. Nothing: the onboard user LED is enough (otherwise LED + 330 Ω resistor).
Wiring
Pin 2 (onboard LED on most DevKit boards); otherwise anode through 330 Ω, cathode to GND.
How it works
millis() counts elapsed milliseconds; when the gap exceeds the period the pin flips. No blocking delay: loop() can run at full speed. In the Arduino IDE, install the « esp32 » board package, pick « Dev Module », the port, then Upload (hold BOOT if detection fails). GPIO34-39 are input-only; avoid GPIO6-11 and GPIO12.
Going further
Wire two LEDs and alternate them, or vary the period with a potentiometer on an ADC pin.
clignotante.ino
// Clignotement non bloquant sur la carte esp32 (millis au lieu de delay).
const int LED = 2; // LED utilisateur de la plupart des cartes
const unsigned long PERIODE = 500; // ms
bool etat = false;
unsigned long precedent = 0;
void setup() {
pinMode(LED, OUTPUT);
Serial.begin(115200);
Serial.println("Clignotement demarre");
}
void loop() {
unsigned long t = millis();
if (t - precedent >= PERIODE) {
precedent = t;
etat = !etat;
digitalWrite(LED, etat ? HIGH : LOW);
Serial.printf("LED %s — heap libre : %u\n", etat ? "ON" : "OFF", ESP.getFreeHeap());
}
}