Skip to content
Michael Miller edited this page Mar 22, 2016 · 1 revision

The uploaded fails after flashing my sketch on a Leonardo and Arduino Micro based Arduinos.

For the ATmega32u4 boards like these, they have special USB hardware that makes them unique. Please refer to the Guide for Leonardo and Arduino Micro for more details.

In the Guide linked above, this series of Arduinos requires that the Loop() have a long delay in it. But the delay(1) as suggested isn't even long enough. I found it really required at least a 500ms and this still had occasional problems. A delay of 3 seconds I found never had issues.

This sort of delay IS NOT A GOOD SOLUTION for any sketch. The Task library needs the fast loop so it can schedule the different tasks quickly. Unfortunately as it stands, with these AVR chips and this Task library, you will need to live with the following annoying flashing procedure.

Flash steps to recover a Leonardo or Arduino Micro

The following steps will allow you to recover from this situation.

  • Connect your Arduino via USB cable.
  • Open the Arduino IDE and load the "Blink" example.
  • Open the Tools/Port menu and see what the normal serial port it uses.
  • Now for the hard part. With these steps you must be reasonably fast. You must finish these before the Arduino disconnects again or else the correct port menu listing won't be accessible. You will probably need to repeat these one or two times before you get the cadence down.
  • Reset the Arduino (Leonardo has a button), and
  • check which port in the Tools/Port menu is listed for it (for a very short period of time) and
  • choose that port in the IDE under the menu Tools / Serial Port.
    (the hard part is over)
  • Press the Reset again on the Arduino and, immediately after, press the Upload button in the Arduino IDE.
  • Your Arduino should start the blink program shortly after the Upload and it is now "healed".

You will need to reselect the normal port for any further uploads after this one.