4

I just uploaded a sketch to my Arduino Leonardo, which presses a key on the keyboard. The code was unfortunately bugged and now as soon as the Arduino is powered on, the key is being pressed.

When I try to upload a new sketch that fixes the issue, I am unable to do so as the Arduino is executing the sketch, preventing the new sketch from being uploaded.

How can I prevent the Arduino from executing the sketch once powered on? Pressing the reset button or wiring it in does not work...

dda
  • 1,595
  • 1
  • 12
  • 17

1 Answers1

6

The Leonardo should wait a couple of seconds after resetting to see if a new sketch arrives.

  • Power off the board completely (remove the USB cable).

  • Hold down the Reset button, and keep it held down (or, run a jumper wire from the RESET pin to the GND pin). This stops the problem sketch from starting.

  • Still holding down Reset, reconnect the USB cable.

  • Start uploading a sketch that does not have this problem (eg. Blink) Once the IDE reports "Uploading" release the Reset button (or remove the jumper wire).

Nick Gammon
  • 38,901
  • 13
  • 69
  • 125