Arduino digitalRead reading wrong
What you have is called a Floating
pin. Digital Input pins are very sensitive to change, and unless positively driven to one state or another (High or Low), will pick up stray capacitance from nearby sources, like breadboards, human fingers, or even the air. Any wire connected to it will act like a little antenna and cause the input state to change. And I mean any wire, the trace on the board, the wire to the breadboard, the breadboard pin, even the metal pin of the IC itself.
This is refereed to in the Arduino reference page:
If the pin isn't connected to anything, digitalRead() can return either HIGH or LOW (and this can change randomly).
If you look at the Arduino Digital Pin Tutorial:
This also means however, that input pins with nothing connected to them, or with wires connected to them that are not connected to other circuits, will report seemingly random changes in pin state, picking up electrical noise from the environment, or capacitively coupling the state of a nearby pin.
Often it is useful to steer an input pin to a known state if no input is present. This can be done by adding a pullup resistor (to +5V), or a pulldown resistor (resistor to ground) on the input, with 10K being a common value. There are also convenient 20K pullup resistors built into the Atmega chip that can be accessed from software. These built-in pullup resistors are accessed in the following manner.
pinMode(pin, INPUT); // set pin to input
digitalWrite(pin, HIGH); // turn on pullup resistors
These weak pull resistors force the input pin state into a known state, and are easily overwritten by stronger input voltages, like a direct connection to ground or +5v.
This is normal. Unless an input is connected to something, it will show HIGH or LOW or constantly changing. This is described by the digitalRead reference page on the Arduino web site.
The input pin behaves with some small capacitance, so briefly connecting to 3V3 or 5V will charge the capacitance. You may find a similar effect using a bare finger.
You can avoid the problem by adding a large value resistor between the pin and GND.
Ask yourself why you expect zero?