> In my circuit, I am using all the 8 pins of Port B and pin 6 of Port A as > inputs to detect the closing of 9 PB switches. The PIC used is 16F628 with > internal RC Oscillator. Port B weak pull-up is enabled and PortA.6 has a > 4.7K pull-up resistor. > > As I am running short of I/O pins, I want to use an IC to reduce the number > of pins used by the PIC for detecting key pressings. After a search through > CMOS data book, I found 74HC147 (10 to 4 Priority Encoder) almost ideal for > the purpose. With this IC, I will need only 4 pins of the PIC and as many as > 5 pins will become available. > > Now, my question: Is there a better IC for the purpose? > Please let me know if there is. Yes, the PIC that you already use. N I/O lines can be used to detect N * ( N - 1 ) switches. The details are somewhere of Stef's pages I posted a summary afew days ago I think on comp.arch.embedded: Take N lines, each with a pull-up resistor (or pull-down, suit to your taste). Make a self-matrix, so you have N^2 cross-points. Except for the diagonal (where a line matches with itself) put a switch and a diode in series between the two crossing lines. Now to detect a particular switch closure: make in trurn all lines but one input, the one is a low output (or high for pull-own R's). Only one slected low output will pull one input low. Note: does NOT work well with multiple switches closed! Can probably be simplified with only one diode per line instead of one per switch. Someone commented that with one diode per switch multiple switches closed can be detected, and that one diode per I/O is sufficient when multiple switch closure need not be corretly detected. Wouter van Ooijen Van Ooijen Technische Informatica: http://www.voti.nl Jal compiler for PIC uC's: http://www.voti.nl/jal -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.