Hi all.
Today the Arduino Leonardo board arrived.I wanted to make a project "Steering wheel" on the basis of this board. It ended up that the board just doesn't accept the code.
Anyway, I used the MMJoy2 program, installed the firmware on the board required by the program and realized that I do not want to do a project through it, and the board already displayed as a controller on a regular basis, somehow I managed to remove the firmware and now in device manager when connecting the board again called its name, but when I want to upload the code or press the Reset button the board appears under the "Unknown device".
And then there's this error:
avrdude: ser_open(): can't open device "\.\COM16": The system cannot find the file specified.
I would like to know if there is any way to fix it. Thanks xD
Hi @senk0re. Due to the USB stack running on the same microcontroller as your sketch on the Leonardo, it is possible for code in your sketch to break the USB functionality.
Fortunately, the program that handles uploads (bootloader) is stored in a separate section of memory and can not be broken by the sketch code.
The only tricky thing is that the bootloader has to be activated at just the right time during the upload. Normally this is done by some special code that runs in the background of your sketch code recognizing a 1200 baud connection as the signal to reset the microcontroller and start the bootloader. However, in your current situation, that system won't work so you'll need to manually reset the board to activate the bootloader.
You need to get the timing right. If you press the reset button too early, the bootloader will have already timed out by the time the upload starts. The tricky thing is that when you press the "Upload" button in Arduino IDE, it first compiles your sketch before starting the actual upload. So you need to wait until after the compilation finishes before pressing the reset button.
Try this:
Select Sketch > Upload from the Arduino IDE menus.
Watch the black console window at the bottom of the Arduino IDE window until you see something like this:
Sketch uses 444 bytes (1%) of program storage space. Maximum is 30720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables.
Maximum is 2048 bytes.
Immediately press and release the reset button on the Arduino board.
After that, the sketch should upload successfully.
If the problem persists after a successful upload, you know there is something in your sketch that is breaking the USB functionality. You can verify this by uploading the File > New Sketch sketch, after which the board should be recognized by your computer and you should be able to upload normally. If the uploads work normally after uploading that sketch, but not after uploading the previous sketch you were using, then you will know the issue is caused by that other sketch
Now that you know how to recover your board, that should be manageable.
Thank you for your reply.
No it doesn't work, maybe I messed up the board completely, before when I pressed Reset in the device manager the arduino Leonardo bootloader board appeared, now when I press the button I get a notification and "Unknown device".
And also with the completely new sketch I get the same error
With me you can enter the bootloader by pressing the button 2 times in a row (MKR Wifi 1010).
I got this error often too. It comes when there is an error in the code. You could post that too. If you are then inside the bootloader, the device will probably be recognized again by Arduino IDE, right? Then all you have to do is upload a completely empty sketch and you're good to go.
This would also be a guide to what else you could do:
The Arduino IDE only recognizes the card when it is connected first time, when you try to enter bootloader mode or upload the code, the card immediately becomes unrecognized.
There can be no error in the code, it is completely clean:
void setup() {
// put your setup code here, to run once:
}
void loop() {
{ // put your main code here, to run repeatedly:
}