Cheap PIC KeypadI had for some time been looking for a cheap pic keypad. A standard phone style keypad can be ordered from several distributors online, but I was looking for something that would give more than the usual 0-9 * and hash keys. Pound Shop calculators seemed an ideal solution, the larger models offering good size keys with decent travel. However (investing my pound) I found that these are implemented using a plastic sheet with the key contacts made from conductive paint - a marvel, but not something I could interface using a soldering iron and all of my attempts to use such a keypad had failed. Recently, the local pound shop got a batch of 'folding travel alarm/calculators', in for a penny I thought and bought one - the other half thinks I'm mad having several cheap calculators with missing keypads! This time however, I found exactly what I was looking for (although the keypad itself is not as user friendly as the larger desk calculators), due to the three part folding construction, the usual 'film' pcb is not used - it would complicate the construction of the spring loaded hinge. Instead, the keypad base is made of a thin single sided pcb and connected with 10 thin wires to the rest of the calculator/clock. Being single sided, it was a simple matter of tracing the tracks to reveal the 5x5 key matrix and altering the code I had already used for reading a telephone keypad in the Voip Desk Phone project.
The pcb has a row of 10 contacts in the top right corner, numbering these 1 to 10,
the x/y key matrix is 1,2,7,8,9 and 3,4,5,6,10. The key layout using this scheme is
Cheap Keypad Matrix
The program files are for a PIC16F876a although any PIC with a couple of free ports will work. I use a 20Mhz clock, but a 16F628 would probably work using it's internal 4Mhz clock if the baud rate settings and some of the key scan delays were altered. Port A0-4 are set to digital and output connecting to pins 3,4,5,6 and 10. Port B0-4 are set to input with weak pullup active (saves external pullup resistors) and connected to pins 1,2,7,8 and 9. As the keypad is not very tactile, I also tied a led and resistor between Port A5 and 5 Volts and the program lights the led whenever a key is being held down. The C Source is Here. |
![]()
Introduction |