I have made a code using involving HID control. But it seems that I messed up, but I can't upload a new sketch(nor edit the wrong code), because my Arduino is constantly doing things like Ctrl+Alt+Delete, Alt+F4... etc. It seems that the only way is erasing the code in the memory, but how can I do so?
-
Use a hardware programmer (USBASP, etc, or an Arduino as an ISP). – Majenko♦ Nov 12 '19 at 15:22
- Do the "button dance" - hold the Arduino in reset, releasing just you see the download start in the IDE. This may (will!) take a little practice to get just the right timing.
or
- Use an external programmer connected to the ICSP connector. This could be a commercially made one, a DIY, or another Uno programmed and connected as an ICSP programmer. How-to's abound on the web.
-
You can't do the "Button dance" on the Leonardo. Holding it in reset will not give you a serial port to start the upload to. Depending on the bootloader version you may get a few seconds after releasing the reset where it presents a COM port before the sketch runs (good luck on Windows - it may take too long to enumerate...), or pressing reset twice rapidly may put it in the bootloader. Best to have a programmer on hand anyway though as a general rule regardless. – Majenko♦ Nov 12 '19 at 22:12