Resistor Ladder > Pressing more than one button

Hi all,

I reproduces a resistor ladder as shown on

I wonder, why the value of the variable AnalogBtn in lineSerial.println(AnalogBtn); is not changing when I press two button simultaneously?

Could anybody please explain?

Regards Mario

if you are using a resistor ladder, then it looks at how much voltage is coming in to a pin and uses that to determine what button is pressed, that's why you need different valued resistors for a resistor ladder to work, if you press multiple buttons then the voltage is changed because the leftover voltage from each button is added up and sent to the board and it doesn't know what to do with it. To press multiple buttons at once, a resistor ladder wont work, connect each button to its own digital pin and use blinkwithoutdelay() to make pressing 2 buttons at once possible

If you need to press multiple buttons, a resistor ladder is not what you want to use. Instead you can use a shift register or even more simply the Keypad library (no extra hardware needed).

It should still change when two buttons are pressed down, though - probably this won't give the behavior you want, but it should still change the value you're reading, because now there would be 2 resistors in parallel to the wire connected to the analog pin and 10k resistor to ground... hence theres a lower effective resistance on that side of the voltage divider, so the voltage should be closer to Vcc.

Recheck connections, especially if using breadboard. Breadboard is notorious for making poor connections.

mariomueller:
I wonder, why the value of the variable AnalogBtn in lineSerial.println(AnalogBtn); is not changing when I press two button simultaneously?

Could anybody please explain?

Regards Mario

Without seeing all the code its impossible to judge.

If you want to use a resistor ladder and be able to distinguish multiple button presses the resistors should double for each switch - 2k, 4k, 8k, 16k etc

You can work this out in a spreadsheet far more easily and quickly than with real resistors.

...R

@markT: The link in the initial post show you everything. Regards Mario

DOes it not change no matter which two buttons you press?
Are you sure your wiring is correct?

mariomueller:
@markT: The link in the initial post show you everything. Regards Mario

If you hope to get free help don't expect someone to have to work hard to provide it. Make it as easy as possible by providing the information here rather than on some other website.

...R

@all: Thanks for your replies. For those you wrote that the resistor ladder does not work in this case are right.
The reason is, that it is a parallel circuit. In a parallel circuit the voltage stays the same.
As analogRead shows indirectly the voltage and not the resistance, a resistor ladder shows no difference when Button2 is pressed or Button1 and Button2 are pressed.

Many Thanks
Mario

@all: I found the solution. It looks like a resistor ladder but isn't

But I do not know how to upload a jpg in the forum. Could pls anybody assist?
Regards
Mario

If its a link then copy the link and paste it here. If you have it on your computer then add it as an attachment.

mariomueller:
But I do not know how to upload a jpg in the forum.

Add it as an attachment.

After you have uploaded the attachment you can use it as the reference in an IMG tag.

...R

here is the circuit

mariomueller:
here is the circuit

I get brain-fade when I see that sort of pseudo photo of a breadboard. It is too easy to misunderstand.

Make a pencil drawing of the circuit and post a photo of that.

...R

It looks like the same circuit with just the voltage reversed.

@Robin: Please take into consideration that some people just start learning. You could loose some potential friends, if you are too educational .

I wish you a nice day and many thx for your replies. Regards Mario

In principle it's do-able. When resistances are in parallel, you add together the conductance of the resistor to get the conductance of the result. So you can binary encode the resistors and get the result … in principle. A typical resistor tolerance is 5% - one in 20. So I wouldn't expect this would work reliably for more than four buttons (16 combinations).

Have a look at shift registers. They are cool, and cheap to buy.

mariomueller:
@Robin: Please take into consideration that some people just start learning.

I did. That is why I asked you to make a pencil drawing.
An experienced person would know that that would be better.

...R