The digital read appears to be random. it changes from high to low whenever it contects with a wire, which is not connected to an energy source. I debugged it with a serialconnection and it indeed showed a random stream of 0 and 1's while only plain wire was connected. I have used different digital inputs but the bug remained.
Anyone knows what might be wrong?
Thanks in advance,
As several have stated you are reading a 'floating' input. To put it simple, I would ask you what would be your expections on reading a input pin that has nothing wired to it (or even a wire which is not wired to anything but the input pin)? If you said it should read LOW that would be in error. The correct answer is that a input pin that is floating is not a legally defined input state and will randomly read either high or low as circuit noise determines. The input pin must be electrically be wired to a voltage source that is either 0vdc (low) or +5vdc (high) to operate correctly.