There is another method, which I have tried, and it does work, but may offend the squeamish. It requires only 1 port pin. Basically it involves connecting the three switches through three different resistors to +5V. Values of say, 10K,22K and 47K would do, from memory. The other side of the switches is joined to form a rail, connected back to a schmitt trigger input on the PIC. A small capacitor (0.1uF) is connected to ground from this rail. To scan the switches,turn this line into an output and pull it low. (you could place a small series resistor like 470 ohms in there if you feel nervous about discharging the cap directly into the PIC). Then you turn the line into an input and loop, counting, (or use the RTC) until the input line reads logic 1. Depending on the time this took, you can deduce which switch or switches were pressed. If nothing happens by the maximum time (depends on RC), then no switches were pressed. Essentially you are doing a single-slope integrating A/D conversion. It does work, and due to the nature of CMOS, the switching point for the input is fairly temperature-independent, and given that modern resistors and capacitors are quite stable, this seems to be quite effective. Of course, it can take a millisecond or more to scan the switches.... > ---------- > From: Dmitry Kiryashov[SMTP:zews@AHA.RU] > Reply To: pic microcontroller discussion list > Sent: Tuesday, December 23, 1997 9:12 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: 3 pushbuttons to 2 inputs? > > Hello John. > > > I don't think there are any particularly good/reliable approaches > for > > detecting more than two buttons with two port pins that can deal > with > > combinations of buttons being pressed. The closest thing I could > > suggest would be wiring buttons with different resistors and using > an > > RC-timer based approach; not sure that would be 100% reliable, > though. > > Why not? There are method with additional external shift register. > It have excellent reliabilty (i practically use it). > First PIC pin clock the shift register ( D input through the low pass > RC > and \C input directly ) I post idea to PICLIST some minutes before. > Register with open collector's outputs. The keys wired directly to > register output. > > Second PIC pin read the second common wire of key's matrix. > > I apply this method to scan up to 16 keys matrix with two PIC pins. > (One additional shift register chip + RC) > > WBR Dmitry. >