I'm new to Arduino. I'm trying out the push button + LED example in the book "Getting Started with Arduino". When I open the serial monitor window in the IDE, or close it. The LED on pin 13 flashes a couple times. Why would opening this monitor affect the digital output pin? I'm using a Duemilanove.
Also, why do I need 10k resistor between the input pin and GND? I noticed if I remove this the input behavior is erratic, but I don't know why.
Why would opening this monitor affect the digital output pin?
Opening the serial monitor initiates the auto-reset feature on the Arduino. The LED on pin 13 blinks when the Arduino bootloader runs during the reset.
Also, why do I need 10k resistor between the input pin and GND? I noticed if I remove this the input behavior is erratic, but I don't know why.
If you disconnect the digital i/o pin from everything, the LED may blink erratically. This is because the input is "floating" - that is, it will randomly return either HIGH or LOW. That's why you need a pull-up or pull-down resistor in the circuit.