Go Down

Topic: digital input pins are too sensitive on the arduino uno (Read 794 times) previous topic - next topic

AndyP93

I've made a program that operates a set of LED's when a switch is pressed. However it appears to me that the switch isn't that ideal and allows a small voltage through (I don't have a multimeter but I'm guessing it's in the region of a few 100mV). In this case it's acting like a piece of wire.

I was wondering, as I do need to use the switch, if there was a way to program the pic to be less sensitive. As in, anything into the input pins <2.5volts is seen as a logic 0?

I know this is sort of answering my own question, but I should probably use the analogue inputs instead..? but I don't particularly want to as there's a limitation of 6 pins. The digital inputs has a lot more pins which is better suited for me. I shouldn't have to use the analogue input pins as the switch should do its job.

any help is much appreciated.


AWOL

Use a pull up or a pull down.
The former are free.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

MarkT

You mustn't let an input "float" (open-circuit) if you want a defined input value, input pins have effectively infinite resistance
and will sense ambient electronic noise quite happily.

So you never connect just a switch to a pin, you always have a resistor pulling one way and a switch the other.  Fortunately
all Arduino pins have built-in pull-up resistors (about 30k ohms) that can be activated by calling
Code: [Select]

  digitalWrite (pin, HIGH) ;


when the pin is an INPUT (this is specific to AVR microcontrollers such as in the Uno and Mega).

Or you can use an external resistor (which can be wired to pull-up or pull-down).
[ I won't respond to messages, use the forum please ]


Sembazuru


You mustn't let an input "float" (open-circuit) if you want a defined input value, input pins have effectively infinite resistance
and will sense ambient electronic noise quite happily.

So you never connect just a switch to a pin, you always have a resistor pulling one way and a switch the other.  Fortunately
all Arduino pins have built-in pull-up resistors (about 30k ohms) that can be activated by calling
Code: [Select]

  digitalWrite (pin, HIGH) ;


when the pin is an INPUT (this is specific to AVR microcontrollers such as in the Uno and Mega).

Or you can use an external resistor (which can be wired to pull-up or pull-down).


An alternate way of activating the internal pull up resistor in your code (one less line of code) is when defining the pinMode(), use INPUT_PULLUP instead of just INPUT. Then you don't need the additional digitalWrite() line that doesn't intuitively (at least to beginners) explain what is happening.
http://www.catb.org/jargon/html/I/I-didn-t-change-anything-.html

Go Up