By popular demand... the explanation:
My theory is that a sketch with runaway serial output is filling a lot of buffers (possibly all of them) in the USB driver on your host system. When you try to upload, either the commands do not get sent because there are no buffers available or the commands get sent and the responses are stuck behind a long queue of previous input.
- Unplug the USB cable. (This causes the USB driver to clear the buffers.)
- Hold down the Arduino Reset button. (This prevents the Arduino sketch from running and flooding the buffers.)
- Plug in the USB cable. (This re-establishes the USB connection so you can upload.)
- WAIT TEN SECONDS. (This gives the USB driver time to settle.)
- Click on the Upload button for a sketch. (This begins the compile process.)
- When you see the "Binary sketch size:" message in the sketch window, release the Arduino reset button. (This allows the bootloader to run and look for upload commands. The message signals the end of the compile process and the start of the upload process.)