🛠 Faire clignoter la LED intégrée (broche 13)
Objectives
Discover the Arduino Leonardo board and its ATmega32u4, turn the integrated LED on pin 13 on and off, and successfully perform your first upload via the Caterina bootloader. On the Leonardo, the LED on pin 13 is connected to pin PB7 of the ATmega32u4: no external components are required.
Hardware
- 1 Arduino Leonardo board (micro-USB connector)
- 1 micro-USB data cable (some cables are charge-only: the COM port will not appear)
- A computer with the Arduino IDE and the
arduino:avrcore installed
Complete code
// LED intégrée de la Leonardo : broche 13 (patte PB7 de l'ATmega32u4)
const uint8_t LED_PIN = 13;
void setup {
pinMode(LED_PIN, OUTPUT); // configure la broche en sortie
}
void loop {
digitalWrite(LED_PIN, HIGH); // LED allumée
delay(200);
digitalWrite(LED_PIN, LOW); // LED éteinte
delay(800);
}
Expected verification
In the IDE, select Tools > Board > Arduino Leonardo, then the corresponding COM port. During the upload, the port disappears and then reappears: this is normal, as the board restarts after writing (the Caterina bootloader remains active for about 8 s). Once finished, the LED should blink with a short-long rhythm (200 ms on, 800 ms off). Modify the delay values to customize the program.
Common errors
- Wrong board model: uploading with "Arduino Uno" selected produces a synchronization error or a sketch that does not start. The Leonardo is an ATmega32u4, not an ATmega328P.
- Charge-only micro-USB cable: the power LED lights up but no serial port appears.
- Changing COM port: the Leonardo re-enumerates over USB at each reset; if the upload fails, retry it within 8 s after pressing the reset button.
- Missing
pinMode: without configuring it asOUTPUT, the pin remains in input mode and the LED stays off or dim.
Other tutorials for this board
- Bouton et console série : Serial (USB) vs Serial1 (broches 0/1)
- Lire un capteur analogique : potentiomètre et ADC 10 bits
- Clavier USB : taper du texte avec la bibliothèque Keyboard
- Souris USB : déplacer le curseur avec la bibliothèque Mouse
- Asservir un servo moteur avec un potentiomètre (PWM)
- Programmer aux registres : interruption Timer/Counter1
Code examples for this board
clignotante.inoArduinobouton-led.inoArduinoclavier-auto-tape.inoArduinosouris-cercle.inoArduinotelecommande-media.inoArduinobouton-clic-souris.inoArduino