I got an Arduino Mega some weeks ago. It is really a masterpiece, but I came to a point that I think is a big problem (at least for me).
I connected the common +5 via 2.2k resistor to dig input and i started reading it. When the +5 is on i got "1" on Serial.print(pin, BIN) and it was stable. But when the +5 are gone (via switch or sth) the "0" are all but stable. If you ask me a percentage - 5% wrong.
Has anyone experienced this too?
What sould i do to read "0" for 0V?
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 more-or-less randomly return either HIGH or LOW. That's why you need a pull-up or pull-down resister in the circuit.