Rescuing an Arduino With a Broken Setup() I may have bricked my Arduino Pro Micro by writing a broken code into the setup() function. When I plug my Pro Micro into my PC, I see it register a COM port for a brief moment before it disappears. Grounding and ungrounding the RST pin causes the device to appear in my control panel again for a brief moment. Attempting to upload the blink example from the Arduino IDE fails, since the COM port disappears before the process can complete.

Is there an alternate way of flashing code to the arduino which I could possibly use to fix this? I have a working Pro Nano I could use if needed.
You can try running the code upload command directly using a precompiled hex file.

Here is how.

Go to preferences in Arduino IDE

Set the Show verbose output during: upload option.

Upload the blink sketch. (arduino does not have to be connected)

After the compilation, check the log window at bottom of the IDE.

You will find a line like this:  

E:\arduino\hardware\tools\avr/bin/avrdude -CE:\arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM3 -b115200 -D -Uflash:w:C:\Users\xxxxxxx\AppData\Local\Temp\build918c1e88f8d0a4c453f8bdfce4cccd30.tmp/Blink.ino.hex:i


That is the actual code upload command.

Copy the command line and paste it into a windows CMD window.  

Edit the COM port to match your Arduino.

Reset the Arduino and immediately press Enter to run the command line.

You may get lucky and the upload "squeaks" through.

You can also move the hex file to another folder so that it is always available for doing a quick recovery.

You could also create a BAT file so that double-click on the icon runs the upload.