Pages: [1]   Go Down
Author Topic: Detecting input as High when not actually active. Arduino uno r3  (Read 426 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Short story: pin 9 detects the input as high, even when there aren't any wires in it(so no way to detect a input) Other pins have the problem also, but only occasionally. Why would this be happening. I have tried if(digitalRead(pinNum) == HIGH); and if(digitalRead(pinNum) != 0); neither seem to work. I have not tried reversing the logic (subtracting from 255 instead of adding from 0) but I do not see why that would make a difference.

The long story:
I wrote a small bit of code that would detect input on pins 2-9 and return the integer value (the input represents binary. This is for part of a  project to help introduce kids to binary, it is a calculator that also outputs in binary on leds. The rest of the project is working) For some reason pin nine always returns as HIGH and some of the other pins do sometimes also. I have noticed that It is only the PWM pins on the last few trials, but this is likely just a confirmation bias, because I think that at one point there were a couple registering incorrectly at a time. I made a separate program just so that I could prove to myself that my other code was not interfering. Now all that the program does is output to serial what pins are detecting a HIGH input.
I have never powered the arduino from anything other than a usb port, so there is no reason that I see that it should have fried. Should I put a resistor inbetween the 5v rail and the input pins? if so how high of a resistance? Do I need a pull down resistor (from the input to ground) to be sure? I would have thought that just having the connection break would be enough, but as we can see what do I know.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Also If I left any info out please forgive me, I will edit the post if you just tell me what I forgot.
Logged

Offline Offline
Edison Member
*
Karma: 64
Posts: 2488
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Show us how you have the project wired in a schematic.
Also if you can, take a good picture of the wiring and attach it to a reply.
If you make a one input circuit using pin 9 only and write a simple sketch what results do you get.
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6127
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Unconnected pins are "floating" and will read high and low randomly.

http://www.cmiyc.com/tutorials/arduino-pull-ups/

Use the internal (or external) pull ups to fix it.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Show us how you have the project wired in a schematic.
I cant take a picture at this time, as I do not have the board with me(I also can not try it with only pin 9) but here is a picture That is not photoshopped in any way of the same exact design as I used. I just unplug the wires that I do not want to detect as HIGH and plug them in when I do want them to.

Unconnected pins are "floating" and will read high and low randomly.

http://www.cmiyc.com/tutorials/arduino-pull-ups/

Use the internal (or external) pull ups to fix it.

I will try this. Thank you for showing me this. I figured that a pullup would not be needed in this case, but you are probably correct, I will try this when I get home.


* Untitled.png (217.97 KB, 480x480 - viewed 7 times.)
Logged

Offline Offline
Edison Member
*
Karma: 64
Posts: 2488
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

From the draw you have all the i/ps going to +5V
Use internal pull ups on the i/ps.
When you unplug a wire, plug that wire into a grounded bus bar (connected to 0 Volts).
Logged

Pages: [1]   Go Up
Jump to: