Pages: [1]   Go Down
Author Topic: digital input pins are too sensitive on the arduino uno  (Read 693 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25858
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Use a pull up or a pull down.
The former are free.
Logged

"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.

0
Offline Offline
Shannon Member
****
Karma: 200
Posts: 11718
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
  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).
Logged

[ I won't respond to messages, use the forum please ]

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

Thanks
Logged

Mid-Atlantic, USA
Offline Offline
God Member
*****
Karma: 30
Posts: 514
"Remember kids, the only difference between Science and screwing around is writing it down." - Adam Savage
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
  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.
Logged


Pages: [1]   Go Up
Jump to: