user80641: Note: This is a reference question (but feel free to write answers of your own!)

I uploaded code that contains a bug that causes my Arduino to immediately reset itself when starting using this code from the AVR libc FAQ. The built-in LED keeps flashing. Because it's in this state of constantly resetting, I'm unable to upload my sketch to it.
I tried holding the reset button while uploading and burning a new bootloader, but neither of those worked.
How do I get my Arduino out of this boot loop so I can upload sketches again?

user80641: 
Start holding the reset button. This is to prevent the Arduino from entering the boot loop.
Unplug the Arduino and plug it back in.
Open a new sketch. Remove all of the code and replace it with int main(){}. This is to create a small program that will upload quickly.
Start uploading the sketch. Avrdude will attempt to upload the sketch ten times -- each time it tries, the RX LED on the Arduino will flash briefly.
Notice how often the LED flashes (0.2 Hz for me). Right before it flashes again, release the reset button. There's a small window of oppurtunity for avrdude to upload the sketch before the arduino starts up. If the TX and RX LEDs flash, success!


80641: <p><em>Note: This is a reference question (but feel free to write answers of your own!)</em></p>
<hr />
<p>I uploaded code that contains a bug that causes my Arduino to immediately reset itself when starting using <a href="https://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_softreset" rel="nofollow noreferrer">this</a> code from the AVR libc FAQ. The built-in LED keeps flashing. Because it's in this state of constantly resetting, I'm unable to upload my sketch to it.</p>
<p>I tried holding the reset button while uploading and burning a new bootloader, but neither of those worked.</p>
<p>How do I get my Arduino out of this boot loop so I can upload sketches again?</p>
 80641: <ol>
<li>Start holding the reset button. This is to prevent the Arduino from entering the boot loop.</li>
<li>Unplug the Arduino and plug it back in.</li>
<li>Open a new sketch. Remove all of the code and replace it with <code>int main(){}</code>. This is to create a small program that will upload quickly.</li>
<li>Start uploading the sketch. Avrdude will attempt to upload the sketch ten times -- each time it tries, the RX LED on the Arduino will flash briefly.</li>
<li>Notice how often the LED flashes (0.2 Hz for me). Right before it flashes again, release the reset button. There's a small window of oppurtunity for avrdude to upload the sketch before the arduino starts up. If the TX and RX LEDs flash, success!</li>
</ol>
