Pages: [1]   Go Down
Author Topic: Push button read errors?  (Read 433 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 212
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hiya,

OK so I currently have  a breadboard with three push buttons on. They all share the same earth and 5v input but through their own 22Kohm resistor to the ground pin. They then all have their own feed to the Arduino's digital pins so that I can read their state.

My problem is that I have got the program to print the state of two of the buttons to the serial monitor and one of the buttons keeps showing as high every few seconds, then it's fine, then every second etc. The other button is fine and only shows as high when pressed, and when pressed it can cause the other random button to stay high?

Any ideas on why this is, is it because they are all using the same 5v input or ground? Also to mention there are other things using the 5v feed such as a LCD screen, thermometer and LED. Could this be an issue?

Thanks, Sam!
Logged

Offline Offline
Edison Member
*
Karma: 36
Posts: leet
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Make sure you have NOT enabled the Arduino's internal pull-up resistors.    With the internal pull-ups enabled, the internal pull-up and your external pull-down are "fighting" (presenting about 2.5V to the input) when the switch is off.

If that's not the problem, you've made a wiring error...   Or, there's an error in your sketch and you're not seeing what you think you are seeing...

It's generally simpler to enable the internal pull-up, skip the pull-down, and have the switch ground (pull-down) the input when it's on.   (You may have to reverse the logic in your sketch.)
Logged

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

I would definitely do a little *finger wiggling* of the components on the breadboard while watching the monitor. If you can get a switch change that is in sync with the wiggling, then there is your problem.
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6637
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

How exactly have you connected the push buttons, and which pins do you have the push buttons connected to? Pins 0, 1 and 13 on an Arduino Uno have other devices connected to them.

The easiest way is to connect the push buttons between the input pins and ground (without any resistors), and enable the internal pullup resistors.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Pages: [1]   Go Up
Jump to: