On Wed, 23 Jun 1999 10:32:22 -0700 James Newton writes: >Another thought, if you don't mind including 20 little diodes between >the 12 >switch contact and the 4 pins, That would be my first choice. One advantage is fast and simple software (just read the port once). One possible wiring would be: Pins Pos. 3210 0 ---- 1 ---X 2 --X- 3 -X-- 4 X--- 5 --DD 6 -D-D 7 D--D 8 -DD- 9 D-D- 10 DD-- 11 -DDD ( '-' is not connected, 'X' directly connected, 'D' connected through diode). The pins would need pull-up or pull-down resistors. If the wiring to the swtich is short the built in pull-ups may be sufficient. By floating the common terminal of the switch, the 4 pins could be shared for other purposes. Using diodes for positions 1-4 would make sharing easier since then the common terminal need only be driven opposite its usual state to disable the switch. This arrangement is optimized to use the fewest diodes: 15. Using more diodes it would be possible to get a conventional binary code. A 16-entry table in the PIC could convert any diode code to whatever you need. It 's certainly not the only way to do it. Others have proposed using an RC timer. I don't like that too much because the total margin for error is on the order of 1/12, or less than 10%. Some sort of auto-calibrating method would definitely be needed. A simple timer may work to resolve 6 positions, use another timer for the other 6. A PIC with A/D could resolve 12 levels easily. ___________________________________________________________________ Get the Internet just the way you want it. Free software, free e-mail, and free Internet access for a month! Try Juno Web: http://dl.www.juno.com/dynoget/tagj.