I've been using the Arduino Pro Micro for a few days now. My program has not been working as intended, so I decided to try to reset the Arduino by wiring the RESET and GROUND pins together 2x. This did not help me, and instead, my Arduino is not not recognized by my PC, and is now listed in device manager as "Unknown USB Device". How do I revert my Arduino back to its original state?
Due to the USB stack running on the same chip as your sketch with this board, it is possible for code in your sketch to break the USB functionality. Fortunately, the upload code (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 wont work so you'll need to manually reset the board to activate the bootloader. As you already learned, due to not having a button, on the Pro Micro this is done by momentarily connecting the GND and RST pins with a wire.
You need to get the timing right. If you do the reset reset 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 the Arduino IDE, it first compiles your sketch before starting the actual upload. So you need to wait until after the compilation finishes before doing th reset.
Do this:
Sketch > Upload
Watch the black console window at the bottom of the Arduino IDE window. As soon as 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.
press and release the reset button.
After that, the sketch should upload successfully. After that, if the problem persists, you know there is something in your sketch that is breaking the USB functionality. You can verify this by uploading the File > New sketch, after which the board should be recognized by your computer and you should be able to upload normally. If so, you will need to find out what it is in your sketch breaking the USB code. Now that you know how to recover your board, that should be manageable.
pert:
Due to the USB stack running on the same chip as your sketch with this board, it is possible for code in your sketch to break the USB functionality. Fortunately, the upload code (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 wont work so you'll need to manually reset the board to activate the bootloader. As you already learned, due to not having a button, on the Pro Micro this is done by momentarily connecting the GND and RST pins with a wire.
You need to get the timing right. If you do the reset reset 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 the Arduino IDE, it first compiles your sketch before starting the actual upload. So you need to wait until after the compilation finishes before doing th reset.
Do this:
Sketch > Upload
Watch the black console window at the bottom of the Arduino IDE window. As soon as 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.
press and release the reset button.
After that, the sketch should upload successfully. After that, if the problem persists, you know there is something in your sketch that is breaking the USB functionality. You can verify this by uploading the **File > New sketch**, after which the board should be recognized by your computer and you should be able to upload normally. If so, you will need to find out what it is in your sketch breaking the USB code. Now that you know how to recover your board, that should be manageable.
I've tried doing this a few times and I can't quite get it to work. This is because there is no way for me to upload to my Arduino because it is not recognized by my computer, and it isn't attached to a COM port. The other problem is, when I click upload, the error message shows up almost instantly, giving me no time to click the button. How do I get around this?
Uncheck the checkbox next to "Show verbose output during: compilation"
Check the checkbox next to "Show verbose output during: upload
Click "OK"
Sketch > Upload
After the upload fails, you'll see a button on the right side of the orange bar "Copy error messages" (or the icon that looks like two pieces of paper at the top right corner of the black console window in the Arduino Web Editor). Click that button.
In a forum reply here, click on the reply field.
Click the </> button on the forum toolbar. This will add the forum's code tags markup to your reply.
Press "Ctrl + V". This will paste the upload output between the code tags.
Move the cursor outside of the code tags before you add any additional text to your reply.
Sketch uses 3460 bytes (12%) of program storage space. Maximum is 28672 bytes.
Global variables use 149 bytes (5%) of dynamic memory, leaving 2411 bytes for local variables. Maximum is 2560 bytes.
Forcing reset using 1200bps open/close on port COM4
processing.app.debug.RunnerException
at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:152)
at cc.arduino.UploaderUtils.upload(UploaderUtils.java:77)
at processing.app.SketchController.upload(SketchController.java:732)
at processing.app.SketchController.exportApplet(SketchController.java:703)
at processing.app.Editor$UploadHandler.run(Editor.java:2055)
at java.lang.Thread.run(Thread.java:748)
Caused by: processing.app.SerialException: Error touching serial port 'COM4'.
at processing.app.Serial.touchForCDCReset(Serial.java:107)
at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:136)
... 5 more
Caused by: jssc.SerialPortException: Port name - COM4; Method name - openPort(); Exception type - Port busy.
at jssc.SerialPort.openPort(SerialPort.java:164)
at processing.app.Serial.touchForCDCReset(Serial.java:101)
... 6 more
This is the error message appearing in them IDE terminal. It is happening because I am selecting COM4, not the Arduino's COM. This is because the Arduino's COM is not there, because the Arduino is not recognized
OK, I understand. This is a tricky situation because the auto reset done during the upload process requires that there be a serial port available that isn't busy. Since you're doing a manual reset for the recovery process, this auto reset isn't actually going to do anything, so it doesn't matter what the port is. Unfortunately, it seems that the COM 4 on your computer is already in use by some other process so COM 4 is not very well suited for this "dummy port".
Are there any other ports listed under the Arduino IDE's Tools > Port menu? PCs will often have an internal serial port named COM 1. If there is another port, please try again with that one selected. If you have a spare Arduino board on hand, you can connect that to your computer to get a "dummy port".
The only other port available to me is "Serial Port" which is grayed out. I do have two other Arduino Pro micros which should allow me to make the "dummy port" you are talking about. What do I do with this dummy port? Do I need to connect both Arduinos?
pert:
OK, I understand. This is a tricky situation because the auto reset done during the upload process requires that there be a serial port available that isn't busy. Since you're doing a manual reset for the recovery process, this auto reset isn't actually going to do anything, so it doesn't matter what the port is. Unfortunately, it seems that the COM 4 on your computer is already in use by some other process so COM 4 is not very well suited for this "dummy port".
Are there any other ports listed under the Arduino IDE's Tools > Port menu? PCs will often have an internal serial port named COM 1. If there is another port, please try again with that one selected. If you have a spare Arduino board on hand, you can connect that to your computer to get a "dummy port".
I'm not really sure what you mean by this. Can you explain what I should do with the dummy port?
Wonderful! An extra Arduino board will definitely do the trick.
Try this:
Connect the working Pro Micro to your computer with the USB cable.
(In the Arduino IDE) Tools > Port > select the port of the Pro Micro.
Unplug the working Pro Micro's USB cable from your computer.
Connect the non-working Pro Micro to your computer with the USB cable.
Sketch > Upload
Wait for the "Sketch uses ..." message to show up in the console pane.
Momentarily connect the RST and GND pins on the Pro Micro.
Hopefully the sketch will now upload and your previously "bricked" Pro Micro will once again be recognized by the computer. After that, you can go back to uploading to the board normally without all this funny business of dummy ports and manual resets.
It might seem strange that I told you to unplug the working Pro Micro, since that causes its port to disappear. However, the Arduino IDE will still use the non-existent port for the auto reset process, which accomplishes nothing, but also doesn't result in an error, which is all we needed in this situation where you are going to manually reset the board.
Yay! In addition to getting your Pro Micro back into service, I think this can be a very useful technique to know. As I mentioned before, it's relatively easy to "brick" these native USB boards, but once you know the trick it's also simple to recover them, so you can feel free to experiment with your sketches in the Arduino spirit without being afraid of killing off boards left and right.