Search code examples
loopskeyboardarduinoemulation

Arduino Leonardo stuck in a loop with infinite keyboard emulation


My Arduino is constantly spitting out keyboard commands after making an accidental error with my code.

Keyboard.write('l');

Now I can't upload any new sketches. I have already tried common Arduino loops solutions like the one from here: How can I "reset" an Arduino board?

The errors I get when trying to upload just before the keyboard starts shooting out code is:

avrdude: stk500_getsync(): not in sync: resp=0x3f

or

avrdude: stk500_recv(): programmer is not responding

It would be great if there is a solution, which wouldn't require buying an external programmer.


Solution

  • I haven't used a Leonardo myself, but it sounds like the auto-reset may be the problem. Try pressing and holding the reset button, and then (while holding it) upload the sketch.

    According to these instructions, you can release the button after the upload has started.