I was working on adjusting code for a joystick controller and after uploading one time, the Arduino is no longer recognized by the pc and I get this error message. If i hit the reset button, it will recognize it for a short time but not long enough to upload a blank sketch. Any help would be appreciated.
I moved your topic to an appropriate forum category @cyclone3113.
In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.
This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.
Thanks in advance for your cooperation.
Hi @cyclone3113. Which Arduino board are you using?
Leonardo
OK, great.
The tricky thing about the boards with native USB capability like your Leonardo is the USB code that creates the CDC serial port is running on the same microcontroller as your sketch. This means your sketch code can cause the board to no longer produce a serial port.
This can be unexpected to those who previously mainly worked with the boards like Uno and Mega with a dedicated USB chip that can never be affected by the sketch code.
The missing port makes it so you can't upload normally any more. However, the situation is really not so bad because there is an independent program called the bootloader in a separate section of memory from your sketch, and that program has its own USB CDC code. So even if the sketch is completely broken, you only need to activate the bootloader to get a port back and be able to upload. This is done by pushing the reset button.
However, the bootloader only remains activated for some seconds before exiting, after which your sketch starts running again and the port disappears. As you discovered already, 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 "Output" panel 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.
The upload should now finish successfully.
Now that you know how to upload to the board even when it is in the state where it doesn't produce a port while the sketch program is running, you will be able to work with sketches that are expected to cause this no port behavior (as might be the case with your joystick sketch) as well as recover the board from sketches that have a bug that produces this behavior.
Thanks. It recognizes it now but i went back to an old sketch that I know works and it says access is denied no matter what usb port i use on my pc. Any ideas why this is now?
Edit:
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.