Why Are All My Buttons Registering High At Once?

Okay this problem is bugging the heck out of me. I sat down today, started rewiring a breadboard of mine for testing. The only problem I have run into, is when I started to test the code, if one button is pressed (reads "HIGH") all of buttons follow. This is the setup I have that causes this

Now, if I change the design to the following, it works correctly, in the sense only the button I press registers as "HIGH"

What am I doing wrong here? To my knowledge these should be the same, but that doesn't seem to be the case. Although, in all fairness, this button wiring style has always confused me a little, I am used to a simple positive in one end, negative the other, and the switch is open by default. So maybe I am understanding these buttons incorrectly

Also, speaking to the code it's simple pin mode registration as "INPUT" and doing a serial print when the digital read returns "HIGH"

In the first image, the switches/inputs are in parallel ??? :wink:

And they're not in the 2nd? This is what's confusing me.

I for fun tried taking off the ground leads on all the buttons ... it doesn't work to register at all. I then tried running resistors between the buttons ... same results.

To me I thought the positive lead runs into the input line, instead of the ground, because, path of least resistance.

In the first image, all input pins are connected together. Therefore, when a button is pressed, all input pins are HIGH. Button form makes us easy to confuse. See detail about button in this tutorial

Wire one side of each switch to ground. Wire the other side to an input set to pinMode INPUT_PULLUP and you will not need any external resistors. The inputs will read LOW when the switch is pressed (active low) so change your code accordingly.

groundFungus:
Wire one side of each switch to ground. Wire the other side to an input set to pinMode INPUT_PULLUP and you will not need any external resistors. The inputs will read LOW when the switch is pressed (active low) so change your code accordingly.

This is what I ended up doing (as I also learn more about these).

What still bugs me is if I replaced the ground wires in the 1st image, with 10k resistors, so it's still serial, I get similar results.

But yet, when I run the resistors to the ground side on the end, it's not the same (and works as it should). What makes this different? Resistance is still present.

We see this many times: someone
connects several things and get
unexpected results. It is best to
get one working correctly then
add another.

To me I thought the positive lead runs into the input line, instead of the ground, because, path of least resistance.

The path of least resistance thing is a myth, it is not true.

Electricity flows in all possible paths, not just the path with the lowest resistance.

What still bugs me is if I replaced the ground wires in the 1st image, with 10k resistors, so it's still serial, I get similar results.

Not too sure what you mean here. Especially the “it is still serial” bit.
If you remove all those ground wires and replace them with a resistor from each switch to ground then that will work correctly.
If you find this not to be the case then include a diagram showing what you have done to the circuit.

For the full story read
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

I think you would do better sketching out the circuit diagram of what you want and what you actually have. It will then become clear hopefully.

James-IV:
And they’re not in the 2nd? This is what’s confusing me.

No they are not in parallel in the 2nd circuit. Parallel means each switch has exactly the same voltage across it.
The second circuit allows the switches to have different voltages across them.

You should realise that 5 buttons require 5 copies of all the components for one button. You need 10 wheels to make 5 bicycles, not 2 wheels.

What you did in the first picture:

No matter which button is pressed, it ends up lifting all the inputs to a high state.

In the second picture, every button has its own ground and resistor connection, making it discrete.

MarkT:
No they are not in parallel in the 2nd circuit. Parallel means each switch has exactly the same voltage across it.
The second circuit allows the switches to have different voltages across them.

You should realise that 5 buttons require 5 copies of all the components for one button. You need 10 wheels to make 5 bicycles, not 2 wheels.

Okay that makes a LOT more sense (the first part especially)

Leroy2007:
What you did in the first picture:

No matter which button is pressed, it ends up lifting all the inputs to a high state.

In the second picture, every button has its own ground and resistor connection, making it discrete.

Yeah I started to realize this might be what it was doing when I started seeing the posts

Grumpy_Mike:
The path of least resistance thing is a myth, it is not true.

Electricity flows in all possible paths, not just the path with the lowest resistance.
Not too sure what you mean here.

Just when I think I am getting an understanding of this all ... you say that LOL

The path of least resistance thing is a myth, it is not true.

Came from the old folk's observation of lightning.

JCA34F:
Came from the old folk's observation of lightning.

Still not true though, even with lightning.

Hi,
Nobody seems to have asked you if you have a DMM to measure voltages around your circuit?
A DMM would have helped you workout how your two circuits worked.

Tom.... :slight_smile:

Grumpy_Mike:
The path of least resistance thing is a myth, it is not true.

Actually its about lightning strikes, not current electricity, and it has some truth in that situation as
the primary path ionizes and becomes an excellent conductor, hogging all the subsequent current.

Hi,
Your first circuit;


Your second circuit;

Tom.... :slight_smile:

MarkT:
Actually its about lightning strikes, not current electricity, and it has some truth in that situation as
the primary path ionizes and becomes an excellent conductor, hogging all the subsequent current.

It is the same thing. It is electricity it behaves in exactly the same way. The big difference is that the air is a non liner resistance and breakers down, given the same load the same thing would happen in an electric circuit.