Digital pins read strange voltages

Hi all,

I just bought my first Arduino (Uno R3).
(My experience with electronics and programming is very limited)

My problem:

When I run the DigitalReadSerial sketch from the examples, the serial monitor shows that digital pin 2 reads voltages (like this: 111001111000) while the arduino is not connected to anything at all except my computer or PC . When I place the Arduino on my bed it seems to read a voltage constantly (111111) unless I touch the plastic frame.
Digital pin 0 and 1 read voltages constantly, no matter what.

Update:
Other digital pins do something similair now.
Another possible clue:
Digital pin 5 shows no voltage (000000) when I put my hand on the laptop.
Digital pin 9 shows constant voltage (111111) when I put my hand on the laptop.
Otherwise they read voltage on and off like pin 2 did.

Aaaand now the pins are reading something different again!

In short:
The digital pins read strange voltages and it seems to change when:

  • I touch the arduino
  • I move the arduino
  • I lift up the arduino
  • I touch the laptop
  • With time

I does this while connected to my PC as well as when connected to my laptop.

Please help!
I have been looking on the internet for an answer, but I can't seem to find any information on this problem.
This is driving me insane!

Thanks in advance

The easy answer is that Arduinos are not fully shielded from stray electrical magnetic fields.
As such the can be prone when not connected to sensors etc to produce strange readings.

You could de-couple items that cause some issues but for the most part its not worth all the extra effort.
or
You could place the Arduino in a metal box to provide some shielding .
or
Use shielded cable for sensors especially those with longer cable runs


See here for an easier explanation.

Thanks!

I just re-did the circuit shown in the tutorial and it works fine now!

It still works when I change the wire to pin 3, but leave the sketch the same.
Is this because pin 2 "senses" the current from the neighboring pin?

If the readings are the same as the designated pin i would suspect something is amiss.

maybe a short across two pins (2,3)
maybe a variable is passing the values along
maybe a CLONE with bad soldering

If the readings are weaker but similar then maybe some type of leakage as you suggest.

'Floating' input pins can take any value - their state is undetermined. Don't even bother trying to read input pins that aren't connected to anything, you're just wasting your time.