🛠 Faire clignoter la LED embarquée et la LED RGB
Objectives
Discover the Arduino Nano ESP32 board (ESP32-S3, u-blox NORA-W106 module) by blinking the onboard D13 LED (LED_BUILTIN) and animating the integrated RGB LED, whose pins are defined by the core: LED_RED = 14, LED_GREEN = 15, LED_BLUE = 16. No soldering is required: everything is onboard.
Hardware
- 1 × Arduino Nano ESP32 (45 × 18 mm, USB-C)
- 1 × USB-C data cable
- Arduino IDE 2.x with the “Arduino ESP32 Boards” package (never the “esp32” package from Espressif, otherwise there are no drivers or debugging support on Windows)
Complete code
// Nano ESP32 : LED_BUILTIN = D13 ; RGB : LED_RED=14, LED_GREEN=15, LED_BLUE=16
void setup {
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT);
pinMode(LED_RED, OUTPUT);
pinMode(LED_GREEN, OUTPUT);
pinMode(LED_BLUE, OUTPUT);
}
void loop {
digitalWrite(LED_BUILTIN, HIGH);
analogWrite(LED_RED, 255); // rouge
Serial.println("phase 1 : rouge");
delay(500);
digitalWrite(LED_BUILTIN, LOW);
analogWrite(LED_RED, 0);
analogWrite(LED_GREEN, 255); // vert
delay(500);
analogWrite(LED_GREEN, 0);
analogWrite(LED_BLUE, 255); // bleu
delay(500);
analogWrite(LED_BLUE, 0);
}
Expected verification
The D13 LED blinks at 1 Hz and the RGB LED cycles through red → green → blue. The serial monitor (115200 baud) displays the phases. If two COM ports appear (“USB” and “DFU”), select the “USB” port.
Common errors
- Wrong board package installed (“esp32” from Espressif instead of “Arduino ESP32 Boards”): LED_RED is undefined and compilation fails.
- DFU port selected in the IDE instead of the USB port: uploading blocks.
- Upload impossible after a crashed sketch: double-press the reset button just after powering on to regain access to the bootloader.
Other tutorials for this board
Code examples for this board
connexion-wifi.inoArduinopoint-acces.inoArduinoble-capteur.inoArduinoneoled-rgb.inoArduinoadc-12bits.inoArduinopreferences.inoArduino