Andre, Yea I am with you. It would be nice to see a PIC replacement of the venerable MM74C922 and/or 23. 3x4 vs 4x4 right? I have been watching with a keen eye for the last 2 months on this subject and think it would be a nifty idea for the interested PICLIST members to corporately solve this and then post to microchip for a APP NOTE... It would be nice to cram this into a 12C508 here 6 pins is all... Reasoning of 12C508 vs 16C55 (nice chip) is 4X less cost and space Assuming that a 3x4 or 4x4 takes 4 bits of static output and a default to the last key pressed (startup is tricky) then only two pins are available of which one must be to the timer to measure a frequency. Internal clock is a must. This frequency could be encoded to a unique single keypress and to ignore any that are chord combos in the code. This code could be an all inclusive 255 addlw+index leaving only 16 successful "outs" from the table. the remaining 255-16 could be all 1s or better yet a F0h for SWAB nibbles later on. These error presses would not invoke a Data Avail pulse(s). Tolerance issues may require 16 good ones and 32 bounded high low; otherwise any good single stroke would be 0Fh to 00h. This could fit in a 508 just barely. This leaves the remaining pin to be a Data avail and could be a multi bit position pulse with a delay to present the serial data of the keypress in a timed fashion (or perhaps not - 2 code sets?) Either way pulse(s). Below I have included some info I dug up on this and an attached GIF showing the front end circuit to create the timer pin drive. Have not gone any farther yet. If there is interest post me on this "a group" and I'll be an active team member. As this is a usefull piece of code... Eric Borcherding Connect Any Keypad With Any Microcontroller Using Only One Pin SAMUEL KEREM Patton Electronics Co., 7622 Rickenbacker Dr., Gaithersburg, MD 20879; (301) 975-1000; fax: (301) 869-9293; e-mail: samuelkerem@juno.com After "Use A Tiny Microcontroller With A Large Keypad" was published (electronic design, Sept. 2, 1997, p. 166), I got a number of responses that prompted me to develop a corollary design. Presented here is a design applicable to microcontrollers not equipped with a built-in ADC. Looking at the figure, you'll notice a familiar 4x4 keypad with a single difference--each row and column are separated by a resistor. If key #1 is pressed, the resistance between nodes A and B (R1AB) is equal to 1.5*R; for key #2--R2AB = 1.5*R+R = 2.5*R; and so on ... key #N--RNAB = N.5*R. This variable resistor network is connected to a 555 timer (CMOS version), configured as an oscillator with the period of oscillation equal to T = 1.4*RAB*C, directly proportional to RAB. Click on the above image for a larger view Adding large keypad matrices to microcontrollers without built-in ADCs is practical using this modified keypad arrangement. Up to 500 keys can be scanned at rates up to 8 characters/sec. The oscillator runs only when a key is pressed, causing an interrupt request for the microcontroller. The INT0 pin is set up as edge-sensitive. The general algorithm can be described as: 1) after detecting the edge on the INT0 pin, wait 20 ms to eliminate ringing; 2) detect the next edge and start the internal timer; 3) the following edge stops the internal timer. The measured period (the time between two consecutive positive edges) will define the key number. Any microcontroller with a built-in timer (the vast majority of microcontrollers) can implement this idea. For a specific example, I will use the 8051-family microcontroller with a 12-MHz clock. In this situation, the single count of the timer will be 1 5s. If we choose 47 nF for the capacitor and 3.9 k as the resistor value, we will have T = 1.4*R*C = 256.6 * 256 5s. That is the period difference between oscillations produced by two serial keys. After calculating the period interval produced by any key pressed, we need only to make integer division by 0xFF (25610) to get the key number of the depressed key. The value for R1 =1.5*R is chosen to provide the highest error margin for the elements by moving the period value in the middle of two consecutive numbers. Some possible sources of errors in this application are: 1) component tolerances; 2) 256.6 5s instead of 256 for 1% resistors; 3) the closest value to 4*R, if R = 3.9k, will be 15.4K or 15.8K instead of the calculated 15.6k., an additional 1% error for each following column; 4) the 555 oscillator inaccuracy--temperature drift of 75 ppm/C0 and variation 0.03% for a power- supply variation of 10.1 V Attachment converted: wonderland:ONEPIN.GIF (GIFf/JVWR) (00025477)