12 keys keypad to microcontroller

Thread Starter

CVMichael

Joined Aug 3, 2007
419
I bought this keypad, but the problem is that I don't want to use 12 of the microcontroller's pins.

What can I do to minimize the pins used by the microcontroller to interface with this keypad ?

[edit]
LOL... right after I posted this, I realized that I could use some resistors in series, from VDD to VSS, where each key is connected to one of the resistors, therefore when a key is pressed it will give a diferent voltage. That should work if I connect the output to the ADC of the microcontroller.

So I think I just solved my own question. :)
 
Last edited:

John P

Joined Oct 14, 2008
2,026
Well yeah, but you'd have been better off to use a matrix-connected keypad with 4 pins for the rows and 3 for the columns. Or would 7 pins still be too many?

Incidentally, I'm seeing that the contact resistance for that keypad is up to 200 ohms. That's worth noting if you're going to be using an analog circuit on the output.
 
Last edited:

Thread Starter

CVMichael

Joined Aug 3, 2007
419
Yea, 200 ohms won't impact the resistor circuit much if I use 10K & 20K resistors for the DAC. Also I don't think I will ever need to press more than one key at the same time, therefore the DAC does not have to be precise.

By DAC, I mean something like this:
 

JDT

Joined Feb 12, 2009
657
Well, it will probably work but with a large component count. Multiplexing with 7 pins is nicer. If you have the pins.

Also, most micro-controller circuits with keypads usually need to de-bounce the key presses. The PIC, and i'm sure others, have internal pull-up resistors on some pins and the ability to generate an interrupt on pin logic level change. So, your code can generate an interrupt when a key is pressed and run a timer or counter.

Not so easy to do this with your analog input method.
 

rjenkins

Joined Nov 6, 2005
1,013
You could also use a few small diodes to encode the individual keys to a four bit value 1-12, then use four inputs on the MCU with either pullups or pulldowns, depending where you prefer the common (ground or V+).
 

Thread Starter

CVMichael

Joined Aug 3, 2007
419
You could also use a few small diodes to encode the individual keys to a four bit value 1-12, then use four inputs on the MCU with either pullups or pulldowns, depending where you prefer the common (ground or V+).
4 bit is acceptable, because then I can also use the interrupt (PIC's PORTB interrupt on change) when key is pressed, right ?, can you give me a schematic for that ? (say with common ground)
 
Last edited:
Top