Open
Description
In online documentation page https://www.arduino.cc/en/Tutorial/DigitalReadSerial there are two errors:
- circuit image shows not proper pin-2 connection to a breadboard. IMO it should be connected to the same leg of a pushbutton as a pull-down resistor to stabilize current when the pushbutton is not pressed.
- In description there is a paragrap regarding LED blinking while on the circuit image and it's description there is nothing regarding LED
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 doesn't have a solid connection to voltage or ground, and it will randomly return either HIGH or LOW. That's why you need a pull-down resistor in the circuit.