Arduino Forum

Using Arduino => Installation & Troubleshooting => Topic started by: salmonel on Oct 17, 2016, 05:30 am

Title: How to unlock my leonardo...
Post by: salmonel on Oct 17, 2016, 05:30 am
OK maybe it is not a good idea but i use a serial.keyboard instruction to be controlled by potentiometer.
So now I need to do modification (with the IDE) to the programation but the arduino type keyboard instruction too fastly to be possible to upload anymore. I tried to un-reset when uploading indication appear but it failed anyway. In fact, the IDE write that upload is completed with succeed but it is not true. 
As you can see, this is the sadly stupid thing that I programed:

void setup()
{
  Keyboard.begin();
 
}

void loop()
{

int pedalA = analogRead(A0);
Keyboard.println(pedalA);

int pedalB = analogRead(A1) + 1024;
Keyboard.println(pedalB);

delay(1);
}

Now, what can I do to succesfully (truely) upload again ?
Title: Re: How to unlock my leonardo...
Post by: ballscrewbob on Oct 17, 2016, 05:45 am
maybe try a simpler sketch like BLINK.

Unplug the LEO and open the IDE and load blink example.
Set the IDE to upload
Then plug in the LEO

Hopefully it will work.

Or you could use the ICSP and reload it from another Arduino.
Title: Re: How to unlock my leonardo...
Post by: dmjlambert on Oct 17, 2016, 06:15 am
Press the reset button and it will run the bootloader for a few seconds, allowing you to upload the blink sketch, but you will have to be quick.   You may have to try multiple times to get the timing right, but pressing the reset button at beginning of upload, and uploading a simple sketch such as the blink sketch is the recovery method.  As Ballscrewbob mentions, you may need to re-burn the bootloader using another Arduino as ISP if you are not successful in getting the timing right.   This is the way Leonardos and Arduino Micros are.

It is OK to use Keyboard or Mouse.   While developing sketches that use Keyboard or Mouse, I recommend putting a delay(5000); in the Setup section before initializing Keyboard or Mouse.   That way the Leonardo will accept new sketches more reliably.