Problems with Serial writing in loop

Hi there,

I've got a big (and bad) problem :frowning:

I played a bit around with my Arduino Duemillanove and than I made a big mistake, I uploaded this sketch:

// WARNING: THIS CODE IS EVIL!!! DON'T UPLOAD IT TO YOUR ARDUINO!!!
void setup()
{
  Serial.begin(9600);
}

void loop()
{
  // [...] here was some code, which is really really fast executed
  Serial.write("Hello World");
}

Now, I think you can see my mistake. Everytime when loop is called, it tries to write "Hello World" to the USB Serial.
Ok, that doesn't sound bad, It's much times worse than you think; I can't anymore connect to the socket of the Arduino, I tried to reboot it already hundreds of times, without any success. :frowning:
My other problem is, that I haven't got any possiblity for reprogramming the ATmega with the Header PINs, because I haven't got any tools in this relation and I haven't got any other ATMega.

Please help me, with my stupid problem.

Thanks.

Try this:

Unplug the USB cable.
Hold down the reset button of the Arduino.
Plug in the USB cable.
Click on the 'upload' button to upload a new sketch.
When you see "Binary sketch size" in the IDE, release the reset button of the Arduino.

I hope that will keep the Arduino from flooding the USB buffers before you can upload a sketch.

1 Like

Just hit the reset button right after it finishes compiling. The timing of pressing the button will vary.

@johnwasser

Thousand thanks. That really worked. :smiley:
And I tried to press the reset button in the right moment ... :roll_eyes:

That was some of the things, I will never do again with my Arduino :slight_smile:

cheesetornado:
@johnwasser

Thousand thanks. That really worked. :smiley:

I suspect that the flood of characters from the Arduino sketch was interfering with the upload process. Even though avrdude will signal the Arduino to auto-reset if it doesn't flush the received USB data it won't see the expected replies. That's why you might need to keep the Arduino in Reset until the upload is ready.

Now that you know how to fix it you don't have to worry about getting stuck that way again. :slight_smile: