Why do my servos twitch when I click Tools?

When I click the tools menu in the IDE to open it, my servos on pins 8 and 9 twitch, and the led on pin 13 blinks once. Why is that?

Also, in my code I'm transmitting debug data with Serial.print(). When I have the serial monitor open, the RX led on my sparkfun FTDI board blinks. But when I close the window, it stops blinking after a little while. It also starts blinking again for a time when I open the tools menu. Does the Arduino perhaps have code to stop transmitting if it doesn't get any response?

No, when the USB serial connection is made / broken the arduino resets and so starts your sketch again. that is causing the twitch and the light flashing.

But why is the IDE breaking the USB connection when I open the tools menu?

Not sure but the tools menu has the list of serial ports in it, it might be that there is a scan performed of all serial ports to prepare the menu with the correct information to select.

But why is the IDE breaking the USB connection when I open the tools menu?

I too think that when the IDE is first launched it performs a comm port scan to see what comm ports are avalible.

Normally the IDE only opens and then closes the comm port at the beginning and end of uploading. Then if you open the serial monitor in once again opens the comm port until you close the monitor, which once again will close the comm port. This is all in all good behavior for the IDE as it frees up the comm port unless it actually needs to use it.

Lefty

Yes, but that's not what it's doing. I mean, it does do that. But it also opens and closes the com port when the tools menu opens. It's not a big deal, and it's probably for the reason GrumpyMike said, but I was just wondering.

I'm not sure why it would be necessary to open the com ports to enumerate them however. Maybe it's for mac or linux compatibility. I'm pretty sure you can get info on what ports are available in Windows without actually accessing the ports.

Yes, it is a mystery of why just opening the tools menu causes that, I also can't see why, unless it just needs to rescan available comm ports in case something has changed sense the IDE originally opened and scanned for available ports?

Lefty

I think it is just that it needs to scan the ports for the first time the menu is opened and it is just simpler to have the same function call used for every time the menu is open rather than have one for the first time and then another for subsequent times.