Values too close when using analogRead()

Continuing the discussion from Multiple Buttons on 1 analog pin:

I am trying to make this setup where I can read button combinations, and I have the wiring done, but when I use analog read all the combination values overlap. Have I missed a step?
I'm using four resistors, the four lower-value ones from the original exhibition.

Please post a schematic of your project showing the resistor values

What Arduino board are you using ?

image
essentially this, but with a Nano and 2 less buttons.
the resistors are 220 390 680 and 2.2k with a 110k resistor into GND
but the values I'm getting are too close to one another, they're all in the range of 1015-1023

That resistor is 30x the resistance of all the others combined!

Try replacing it with another 2.2K

So are you trying to press more than one button at a time? If so, then your resistors will be in parallel.

It will be quite difficult to come up with a resistor combination that will differ just enough to be noticeable.

Take the 1k, 10k, 100k and 1M (probably a bad example…)

If you pressed (1k || 10k), the output resistance will be 909.09 ohms

10k || 100k = 9090.09 ohms

1k || 1M = 999.0 ohms

So the bigger the difference, the closer the output will be to the lower resistor. It would be very difficult to tell them apart.

Thank you, I don't know why I thought that 110k was the right resistor, must've seen it somewhere else and got muddled up. I feel like a fool now, but oh well, mistakes happen.

If your project requires button combinations, then you can probably get away with a shift register. It would require 3 pins instead of just 1 but it would be much more flexible.

If you understand the basic principles of the circuit you are using, you can easily spot such mistakes yourself. In this case, the principle of your circuit is a "voltage divider". It's easy to understand, just Google to find out. The only difference in your case is that pressing each button creates a different voltage divider.

As @HazardsMind mentions, pressing more than one button at once will create yet more, different voltage dividers. To understand what voltage to expect, you will also need to understand the principle of "resistors in parallel".

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.