🛠 Programmer par FTDI et dompter le bootloader
Objectives
Master the FTDI → LilyPad programming chain: VCP driver, serial port, ATmegaBOOT bootloader (the "pro 8 MHz" hex compatible with Optiboot), automatic reset via the DTR line, and a 57600 baud upload rate for the ATmega328P option. Also learn how to diagnose a misconfigured bootloader or clock.
Hardware
- 1 LilyPad SimpleSnap (or Simple/Main) + "USB Serial" FTDI adapter with a DTR line (the one that handles automatic reset)
- FTDI VCP drivers installed (Windows: manual installation documented by Arduino)
- Optional for recovering a board: ICSP programmer (the ICSP pads exist; on LilyPad USB they are too small for standard pins)
- Watch out for variants: the LilyPad USB (ATmega32U4) is NOT programmed via FTDI but via micro-USB (Caterina)
Complete Code
// Test de chaîne : timing exact + série pour valider bootloader, FTDI et horloge
// Carte requise : « LilyPad Arduino » (ATmega328P @ 8 MHz, upload 57600 bauds)
const uint8_t LED = 13;
void setup {
Serial.begin(9600);
Serial.println(F("Boot OK — 8 MHz"));
pinMode(LED, OUTPUT);
}
void loop {
unsigned long t0 = micros;
digitalWrite(LED, HIGH);
delay(1000); // doit durer 1,000 s pile si F_CPU = 8 MHz
digitalWrite(LED, LOW);
unsigned long t1 = micros;
Serial.print(F("delay(1000) mesure : ")); // ~1 000 000 µs attendu
Serial.print(t1 - t0); // ~2 000 000 => configuré 16 MHz !
Serial.println(F(" us"));
delay(1000);
}
Expected Verification
After uploading, the serial monitor (9600) displays "Boot OK — 8 MHz" followed by lines close to 1,000,000 µs: the bootloader, clock, and FTDI are correct. The automatic reset works: each time you click "Upload", the IDE resets the board without pressing the button. A factor of 2 (≈2,000,000 µs) indicates a 16 MHz configuration.
Common Errors
- "avrdude: ser_open": wrong serial port or missing FTDI driver — install the VCP driver and check the device manager.
- Selecting "Arduino Uno": inconsistent protocol and upload rate, causing the upload to fail.
- Accidentally flashing the "pro 16 MHz" bootloader: everything runs twice as fast — re-flash the 8 MHz hex via ICSP (or another Arduino acting as a programmer).
- Confusing it with the LilyPad USB: no FTDI, it uses Caterina with native USB; uploading with "Leonardo" selected breaks USB communication (recovery via double reset).
- TX/RX swapped on a homemade FTDI adapter: no characters appear, and no error is displayed.
Other tutorials for this board
Code examples for this board
clignotante.inoArduinobouton-led.inoArduinopwm-respiration.inoArduinoluxmetre-couture.inoArduinointerrupteur-tilt.inoArduinoservo-balayage.inoArduino