# False Positives on Arduino Input

I've used analog and digital input for a multitude of applications with the Arduino Uno board. It has continuously given extremely non reliable readings, where the analog input is always fluctuating, or digital read will read true even if it isn't connected to anything. Is there a way when connecting to a digital or analog input pin that will eliminate that problem? Like a capacitor? I'm not very well versed in electronics, I understand basics on transistors, diodes, resistors, etc... But I don't know much about eliminating electrical signal noise. I feel that with so many false positives my ability to create more complex projects is completely shot.

Any suggestions on eliminating all the extra false positives/noise when receiving Analog/Digital Input on an Arduino Uno?

It sounds like you are missing pull up or pull down resistors on your inputs. If you leave your inputs floating you will get unreliable results.

If your input is normally off you'd use a pull down resistor and if normally on you'd use a pull up resistor. This is a simplified way of thinking about it but it makes it easy to know what to expect when reading the input.

When you look at the little schematic it show an open switch and a pull up resistor. This means that when they switch is open Vin will be going thru the buffer to Vout. Vout = Vin here. When the switch is close Vin will go thru the pull up resistor to thru the switch and to ground. The input of the logic gate would have 0 volts and would be directly connected to ground. Thus Vout = Ground.

• That's exactly what I needed to know, I'll make this the answer in 5 minutes when it allows me. Thanks for the super fast response. But to make sure I am understanding the wikipedia article correctly; I just need to add enough resistance straight to my input line to cancel out the false positives? – Mark Y. Dec 17 '12 at 18:41
• No, you need to have a default answer for your input. Updated answer – Hair_of_the_Dog Dec 17 '12 at 18:49
• For digital inputs, in general, no external resistor is required as it is built into the controller and only needs to be enabled from software. Check helloworld922 answer. – jippie Dec 17 '12 at 19:51
• @jippie is correct. The MCU has internal pullup/pulldown resistors but you need to turn them on. Alternatively you can use external resistors if you don't want to rely on the firmware to set these. – Hair_of_the_Dog Dec 17 '12 at 23:16

Digital inputs which may become open should have a pullup/pulldown resistor so that their state becomes defined. Otherewise, they will have an undetermined voltage between [0,5V], leading to sporadic digital readings (as you've noticed). The microcontrollers used by Arduinos have internal pullup resistors which can be enabled.

I'm not entirely sure which is the recommended method as different portions of the Arduino website give different information on how to enable pullup resistors.

The Digital Pins page suggests setting the pinmode to input and writing a high value to the pin.

However, the PinMode function reference has an INPUT_PULLUP constant, which would make more sense to use instead of the round-about method used above.

The same recommendation about using pullup/pulldown resistors goes for analog pins which may become open. Furthermore, you can also try adding a low-pass filter to your analog inputs to reduce high-frequency noise.