🛠 Faire clignoter la LED RGB de l'Esplora
Objectives
Discover the Arduino Esplora board by controlling its integrated RGB (red/green/blue) LED. By the end of this tutorial, you will know how to install the Esplora library, upload a first sketch, and drive the three PWM channels of the color LED without soldering or wiring anything — that is the main advantage of this "game controller" board derived from the Leonardo (same ATmega32u4).
Hardware
- An Arduino Esplora board (referenced A000095, now discontinued from the Arduino catalog but still programmable).
- A micro-USB cable for connection and power (the board is only controlled via USB; no power jack is documented).
- A computer with Arduino IDE 2.x (or arduino-cli) and the
arduino:avrcore installed. - The "Esplora" library installed via the Library Manager.
Complete Code
/* Clignotement arc-en-ciel de la LED RVB de l'Esplora.
La LED est câblée en interne : rouge = D5, verte = D10, bleue = D9 (PWM).
La bibliothèque Esplora fournit writeRGB(r, v, b) : 0 = éteinte, 255 = plein. */
#include <Esplora.h>
void setup {
// Rien à configurer : la bibliothèque gère les broches en interne.
Esplora.writeRGB(0, 0, 0); // LED éteinte au démarrage
}
void loop {
Esplora.writeRGB(255, 0, 0); // rouge
delay(400);
Esplora.writeRGB(0, 255, 0); // vert
delay(400);
Esplora.writeRGB(0, 0, 255); // bleu
delay(400);
Esplora.writeRGB(255, 255, 0); // jaune (rouge + vert)
delay(400);
Esplora.writeRGB(0, 0, 0); // extinction
delay(400);
}
In the IDE, make sure to select the Arduino Esplora board (FQBN arduino:avr:esplora) and then upload.
Expected Verification
The RGB LED on the board alternates red → green → blue → yellow → off every 400 ms. The yellow "L" LED (pin 13) remains off: it is not used here. If you replace 255 with 30, the light becomes dim — pins D5/D9/D10 are PWM outputs, so brightness is progressive.
Common Errors
- Wrong board selected: Choosing "Arduino Leonardo" instead of "Arduino Esplora" works for the core (
leonardovariant) but you will lose the dedicated examples; always choose Esplora. - Missing library:
fatal error: Esplora.h: No such file or directory→ install the "Esplora" library (arduino-libraries) via the IDE. - LED appears "off" in dark red: At full brightness, the red LED may appear on even when it receives 0; verify actual extinction with
writeRGB(0,0,0)in the dark. - Serial port not found: The Esplora uses native USB (CDC, VID 0x2341 PID 0x803C); on Windows, you may need the
.infdriver provided with the core. If a sketch crashes at startup, press Reset and upload within the approximately 8-second window of the Caterina bootloader.
Other tutorials for this board
Code examples for this board
joystick-couleur.inoArduinojeu-boutons.inoArduinoslider-luminosite.inoArduinothermometre-couleur.inoArduinosonometre.inoArduinoaccelerometre-tilt.inoArduino