My Arduino Leonardo is looping

My Arduino Leonardo is looping

I uploaded a code that is causing a runtime error, with that the arduino starts, receives an error and restarts. That way there is no time to upload a new code, because when I try to upload the new code it already restarts and when doing this, windows disconnects and reconnects the leonardo.

I tried to record via USB UART, but I couldn't find in the forum how to connect the DTR pin to Leonardo boards.

How to solve this problem?

Can you help me?

Hi, welcome to the forum.

I have that sometimes as well, when I send too many messages to the serial port.
My solution is to use a USBasp programmer and burn the bootloader in it.

Others say to press the reset button at just the right moment to upload a empty or simple sketch. That is the solution, but somehow I do that wrong, because I can't do that.

There is no DTR, because the Leonardo has a native USB interface. Normally the Leonardo is resetted, when the baudrate is set to 1200 Baud from the PC.
It is normal that the leonardo disconnects from the PC and reconnects when it is resetted. This is because after reset the bootloader starts, and the bootloader connects to the PC as a different device than the USB driver in a sketch.

To overwrite a sketch with a runtime error that always resets the arduino you must hold the reset button and release it when the PC starts uploading. Usually it helps when pressing the reset button twice at that moment. The bootloader runs a little bit longer in this case, and the PC has more time to find it. As @Koepel already stated, it's a bit tricky to find the right moment and may need several attempts. But after that, your Leonardo will behave normally again.

I had tried several times before, but nothing worked!

This is because after reset the bootloader starts, and the bootloader connects to the PC as a different device than the USB driver in a sketch.

Your exact timing tip resolved, THANK YOU VERY MUCH AND @Koepel TOO!