piclist 2007\11\28\175349a >
Thread: four buttons on one A/D pin
www.piclist.com/techref/io/atod.htm?key=a%2Fd
BY : Rob Robson email (remove spam text)

Here's a head-scratcher for the brain trust.  I want to connect four momentary pushbuttons to a single A/D input such that each and every combination of pressed buttons will present a unique voltage to the A/D.  To minimize errors, it seems there should be a wide and fairly even distribution between the fifteen possible voltage levels (not including the "no-buttons-pressed" option).

The proposed circuit consists of four different resistor values, each one tied between the A/D input and a pushbutton.  The other side of each pushbutton is tied to ground.  A fifth resistor ties the A/D input to +5V to complete the voltage divider.

My limited math abilities are hampering my attempts to optimize the five resistor values for a nice safe spread between all the resulting single- and multiple-button voltages.  Has anyone seen or done something like this?  Googling hasn't turned up anything so far.  I'm completely open to changing the circuit if there's a more clever arrangement.