Arduino Hangs and LED Switches On After Serial Monitor is Opened

Opening Arduino's Serial Monitor causes my Arduino Mega to reset, hang for ~9 seconds, and its LED to remain in the "on" state even after setting the LED's pin to output mode. This does not happen when using PuTTY as the serial client, so the problem probably lies with the Arduino IDE.

Test with the following code:

void setup() {

  pinMode(13, OUTPUT);

void loop() {}

Expected behavior is for the terminal to print out "started" without significant delay, and for the LED to go out immediately after calling pinMode(13, OUTPUT).

I once established that after powerup, and bootloader has determined that no new sketch is comming, ie. it is ready to start your setup() routine the following has happened: All variables are set to 0. All pins are set to input, except pin13 which is set to output, and pin13LED is off.

So if yours is on, it is stuck somewhere in the bootloader. Depending on the bootloader (I think) and what is happening on serial input there is some blinking with pin 13 to signal powerup/bootload progress. How much are the RX/TX LEDs blinking?

Powering up the Arduino with an empty sketch causes the pin 13 LED to turn on immediately, turn off briefly, and finally turn back on.

Powering up or resetting the Arduino with the following sketch...:

void setup()
  pinMode(13, OUTPUT);

void loop() {}

... causes the Arduino's pin 13 LED to turn on immediately, turn off briefly, turn back on, remain that way for 2 seconds, and finally turn back off when it gets to the pinMode() call.

Opening the Serial Monitor with the same sketch loaded into the Arduino causes the LED to turn on and never once go out, and the RX/TX lights don't blink at all.

I have a Mega 2560, an older Duemilanove, and a UNO. Loaded with the "Examples, Bare Minimum" from a IDE version 022, LED 13 is OFF whether I power on via USB or external supply.

I suspect you have a corrupted boot loader or something bust on your board. Look around for reloading the boot loader (requires a 2nd board or Programmer). Comming to think of it ... I do not know if you have the newer Opti-loader or the good ol' one (and I do not know how to check)

(BTW - I, too, have a mystical problem with a board behaving differently depending on the seriel connection - but sort of opposite to yours.)

Which revision is your Mega 2560? Mine is Rev 3. IDE is version 1.0.

I don’t have access to a Programmer or second board, but perhaps there’s some way I could check the bootloader’s integrity?

Rev 1 or 2. The bootloader integrity is beyond my immediate knowledge. I used Rev 022 of the IDE, but I am sure that is not of importance. Backward compatability and besides the pre-setup stuff is part of the core, not the bootloader.

Msquare: Rev 1 or 2.

That might explain the difference. Then again, it might not.

I used Rev 022 of the IDE, but I am sure that is not of importance.

It's probably irrelevant with respect to the LED remaining in the "on" state when running an empty sketch (likely due to the pin being set to INPUT rather than OUTPUT), but the more important issue is that the board hangs for 9 seconds as soon as the IDE's Serial Monitor is opened (unlike with PuTTY) and that the LED stays lit even after the pin mode is set to OUTPUT.

did you find a solution the same happens to me