I have an Arduino Leonardo at home, and as the title says, it keeps disconnecting. i don't know what's wrong with it. pressing the reset button or plugging and unplugging it from the computer seems to bring it back for a few seconds, before it disconnects again.
This usually happens if you load a buggy sketch on it. Press the reset button on the board then you have a few seconds to upload a new sketch (use a very simple one to be sure you don't put it into a reset loop again).
Try increasing your delay to maybe 500 and or increasing your baud to 115200. You appear to be flooding the serial port. If you cannot load the blink sketch try this:
- Power off the board completely
- Remove the USB cable
- Hold down the Reset button
- keep it held down (or, run a jumper wire from the RESET pin to the GND pin).
- Still holding down Reset reconnect the USB cable.
- Start uploading a sketch that does not have this problem (I use the Blink sketch).
- When you see the Receive light blink, release the Reset button
Note: I have seen this happen several times when I flood the serial output. An indication is the tx light is stuck on.
This isn't possible on a Leonardo. Even the baud rate is irrelevant as the USB speed is much faster anyway and the baud rate is just an information sent over USB.
That won't work on a Leonardo as the receive light won't change while you hold down the reset button. On an UNO there is a second MCU doing the USB connection but on a Leonardo the main MCU is doint the USB connection while you hold down the reset button you won't even see the Leonardo on the PC because it's disconnected from the USB (logically).
