Push button read errors?

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!

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

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.

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.