I just purchased an Arduino Leonardo. This is my first time using it. I'm trying to use it as a mouse. I've had successful results: I was able to upload various projects, and it behaved just as expected.
However, at one point, I tried uploading a more complex code, and it got stuck at "Uploading". Unfortunately, I do not have the code that I uploaded prior to that one, but it was extremely simple; a simple serial print in loop, and nothing else. I wouldn't expect it to break because of such a simple piece of code.
I tried the solution that I've read everywhere to such a problem: I pressed the reset button before hitting upload, and released it when "Uploading" appeared. It still didn't work - I get a new error on every try, but the most common one is: "An error occurred while uploading the sketch".
I always ensured that the code was uploaded using the right COM ports. I also tried every other available one because I'd heard of a virtual port that was used for serial communication...
Does anyone have any idea of how I could go about that?
Ballscrewbob:
Did you try pressing the rest during upload ?
Timing can be a little awkward
Yes, I did. I tried different timings, didn't work. Unless there's something really obvious about that reset thing that I don't get, I think I tried it every possible way...
I recommend you to do File > Preferences > Show verbose output during: upload(check) so that you can watch the progress of the upload.
After the upload fails you will see a button on the right side of the orange bar "Copy error messages". Click that button then paste the error in a message here USING CODE TAGS(</> button on the toolbar).
I have managed to overwrite the bootloader on my Leonardo several times. I just burn the bootloader again to fix it. I think it's usually caused by starting an upload with a different board like an Uno selected from the Tools > Board menu, then realizing it's wrong and change the board selection before the upload starts. So it uploads the sketch compiled for a different microcontroller. I guess I should have known better than to do that but the IDE really should be smart enough to handle it correctly(upload for the board that was selected at the time the upload button was clicked).
I tried the timing method several times. From what I understand, my timing seems to be good since the board is detected and the programmer is trying to upload to that specific board on COM2. However, the programmer is not working...
How would you suggest I go about burning the bootloader?
Arduino: 1.6.12 (Windows 10), Board: "Arduino Leonardo"
...
avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch
System wide configuration file is "C:\...\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.0.1-arduino5/etc/avrdude.conf"
Using Port : COM2
Using Programmer : avr109
Overriding Baud Rate : 57600
AVR Part : ATmega32U4
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PA0
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 9000 9000 0x00 0x00
flash 65 6 128 0 yes 32768 128 256 4500 4500 0x00 0x00
lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : butterfly
Description : Atmel AppNote AVR109 Boot Loader
Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding
Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
You would need another working Arduino to use as an ISP programmer, or you would need a dedicated programmer such as USBasp to burn the bootloader. Also, have you tried rebooting your PC?