>Robert Nansel wrote: > >Excellent idea, but check polarity of D3 & D4. With polarity shown in >you >schematic SW3 seems to be never scanned. > >WBR Dmitry. > -------8<-------- >> >> Vcc >> SW3 | >> __I__ R1 >> + | | >> +---o o---o----D3----o--------o----------o-------| B0 >> | | | | | >> R3 | SW1 | o SW2 | o | >> | | -| -| | >> Gnd | | o | o | >> | | | | >> | Vcc |+ | | >> | | D1 D2 | >> | R2 | |+ | >> | + | | | | >> +----D4----o--------o----------o-------| B1 >> | >> >> To read the status of the switches, you must set the TRIS & data bits so as >> to cycle B0 and B1 through the following three states: >> >> B1 B0 Meaning >> --------------------------------------------------------- >> >> State 0 >> out low in high Neither SW2 nor SW3 pressed >> out low in low SW2 OR SW3 pressed >> >> State 1 >> in high out low Neither SW1 nor SW3 pressed >> in low out low SW1 OR SW3 pressed >> >> State 2 >> in low in low SW3 pressed >> in high in high No switch pressed >> -------8<-------- The schematic is correct, but I see now that I used a confusing convention for diode polarity. Thanks for pointing that out. I meant the "+" sign to indicate the direction current would flow FROM the diode when forward biased (instead of the more usual direction of current flow INTO the diode). Your way is more logical, though, so here's how the original circuit would look with the "+" representing the ANODE of the diode: Vcc SW3 | __I__ R1 + | | +---o o---o----D3----o--------o----------o-------| B0 | | | | | R3 | SW1 | o SW2 | o | | | -| -| | Gnd | | o | o | | | | | | Vcc | |+ | | | D1 D2 | | R2 |+ | | | + | | | | +----D4----o--------o----------o-------| B1 | Again, the "+" indicates the direction current will flow INTO the diode when it is forward biased. With programmable pullups on B0 & B1, R1 & R2 can be eliminated. If you want to gamble that the code will never set either B0 & B1 as high outputs, you could even eliminate R3, though I wouldn't. --BN ---------------------------------------------------------------------------- Country Robot "Modular robot components 69 S. Fremont Ave. # 2 for education and industry" Pittsburgh, PA 15202 ----------------------------------------------------------------------------