Hi
I have noticed a problem on one of my UNO's Digital pins.
Let me explain....
I boot up the UNO, it has no connections on any of the pins.
If you put it into the main loop to do a digital read on pin 7 I get 0 all the time which is correct.
Now if I add a dupont jumper wire into D7 and not connected to anything on the other end and run the loop it just keeps flipping between 0 and 1 even though it's not connected to anything.
If I pull the jumper wire out of D7 it then sticks at 0.
Any ideas anyone why it keeps flipping between 0 and 1? Is the UNO on it's way out?
Thanks
It is because the pin is floating at an unknown voltage, maybe HIGH, maybe LOW
Set the pinMode() of the input pin to INPUT_PULLUP to turn on the built in pullup resistor to hold the pin HIGH unless you expressly take it LOW by connecting it to GND
Hi
I have noticed a problem on one of my UNO's Digital pins.
Let me explain....
I boot up the UNO, it has no connections on any of the pins.
If you put it into the main loop to do a digital read on pin 7 I get 0 all the time which is correct.
Now if I add a dupont jumper wire into D7 and not connected to anything on the other end and run the loop it just keeps flipping between 0 and 1 even though it's not connected to anything.
If I pull the jumper wire out of D7 it then sticks at 0.
Any ideas anyone why it keeps flipping between 0 and 1? Is the UNO on it's way out?
Thanks
Change that to INPUT_PULLUP, then the pin will not be floating and any loose wire attached wil not act as an antenna picking up stray electronic fields.
It will return 1 until you take the pin low (ground) and then it will return 0.
Thanks for the replies. I am at work at the moment so will try when I get home.
The reason for putting in the jumper wire was that I had D7 wired up to a PIR sensor following a tutorial and I say geting flipping 0 or 1, so I thought the PIR may of been faulty so plugged in another and still got the flipping 0 or 1. I then noticed that it all stopped when I pulled the jumper out of D7 and then plugging the jumper in it then went 0 or 1 again. This is why I thought D7 might be faulty
When I get home I shall take all your suggestions onboard and thank you all.