Hi, take a look at this nice Microchip document, in the tip #5 you have the answer http://ww1.microchip.com/downloads/en/DeviceDoc/40040C.pdf HTH 2007/11/28, Rob Robson : > > 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. > > Many thanks in advance for your skulduggery, > RR > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- Ariel Rocholl Madrid, Spain -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist