My Pro Micro gives the below error after uploading my sketch. Any ideas why? I have tried with multiple Pro Micros and have checked with nothing connected to it at all except the USB cable. Something about the sketch appears to be breaking USB functionality.
This is my sketch:
In addition to solving the issue with the sketch, any ideas how I can restore my Pro Micros so I can flash them again?
tangles:
Something about the sketch appears to be breaking USB functionality.
It had a quick look and nothing obvious jumped out at me.
tangles:
any ideas how I can restore my Pro Micros so I can flash them again?
The process requires that you reset the Pro Micro. Since it doesn't have a reset button. You'll need to prepare a wire connected to the RST pin that you can quickly connect to and then remove from GND.
File > New
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 3462 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.
Connect and then disconnect the RST pin to GND
The upload should now finish successfully. After that, you should be able to go back to uploading to your Pro Micro normally. However, if you upload the problematic code again, the same problem will like come back.
Can't you also do a "double tap" on reset (ie, ground reset, disconnect briefly, ground again and disconnect - as if pressing the button twice quickly) to make it stay in the bootloader?
But yeah - this is the price you pay for a board with native USB - if your code malfunctions badly enough to hose the USB, it becomes more complicated to upload code.
Edit: I don't see a smoking gun in that code either. You have tried reconnecting it to USB after disconnecting everything, right? (am wondering if the power drawn by the connected devices, particularly the power hungry ESP8266, could be bringing down the pro micro. Remember that the ESP8266 is a 3.3v device (though the pins are 5v tolerant) - it needs a 3.3v regulator, and it needs it's own regulator (or a heavier duty one than most arduino boards provide for 3.3v))
DrAzzy:
Can't you also do a "double tap" on reset (ie, ground reset, disconnect briefly, ground again and disconnect - as if pressing the button twice quickly) to make it stay in the bootloader?
I see that claim a lot, but in my experience it's not true. Double tap on the Leonardo and Pro Micro clones I have is no difference from a single reset. The bootloader runs for 8 seconds (no longer than after a single press reset), then exits. You might get away with getting the upload process started before the bootloader times out, but there's no guarantee of that. In order to make sure the lack of double tap support wasn't caused by some random bootloader the Chinese manufacturers put on my boards, I just tried it after burning the Arduino Leonardo, Arduino/Genuino Micro, and Sparkfun Pro Micro (5V, 16 MHz) bootloaders. I did discover that with the Sparkfun Pro Micro bootloader, the bootloader is only activated by the double tap, but it still times out after 8 seconds.
All my Pro Micro clones have come bootloaded as Arduino Leonardo.
With my MKR boards, double tap does cause it to stay in bootloader mode indefinitely
I did getting going again with the double-press to enter the bootloader for 8 sec, thank you very much for that
Not sure why but it seemed to be setting INPUT_PULLUP on pin 20, but doing so on it's own in a blank sketch doesn't cause the issue. No matter, I used a different pin and it doesn't happen any more