Using ADC for multiple Switches detection

Thread Starter

DJ_AA

Joined Aug 6, 2021
152
Hi All

I am working on a design, and require about 5-6 GPIO pins for various Switch operations.

But I have about 2 spare GPIO pins available.

I do not want to have I2C GPIO extender and have my system continuously poll it. But I might have one if I need additional LED GPIO.

Has anyone used an ADC with various resistors values to determined which switch has been pressed? Is there any disadvantage of this method?
 

KeithWalker

Joined Jul 10, 2017
2,306
I have used this method. It is a very effective way of reducing the number if used input pins but make sure you take into account the possibility of two switches being pressed at the same time.
 

Ian0

Joined Aug 7, 2020
4,863
It is a very common method for membrane keypads. If you scale the resistors 1:2:4:8:16 you can deal with multiple switch closures.
I suppose it could extend to any number of switches, but unless you have some high-precision resistors more than 5 is probably pushing your luck.
If you have changeover switches (which you probably don’t, but you just might), you can arrange to disable other switches when one is pressed, the you are not so constrained on choice of resistors.
 

Thread Starter

DJ_AA

Joined Aug 6, 2021
152
Great. Yes we aim to use a membrane Keypad.

Our aim is to keep it as simple as possible as far as its possible.

There could be a possibility two key can be pressed at once, so how would scaling help involving this issue. The max switches we would need is about 6.
 
Top