12 keys keypad to microcontroller

Discussion in 'General Electronics Chat' started by CVMichael, Apr 12, 2010.

  1. CVMichael

    Thread Starter Senior Member

    Aug 3, 2007
    416
    17
    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: Apr 12, 2010
  2. R!f@@

    AAC Fanatic!

    Apr 2, 2009
    8,754
    760
    Bingo.......
     
  3. CVMichael

    Thread Starter Senior Member

    Aug 3, 2007
    416
    17
    Thanks for confirming...
     
  4. John P

    AAC Fanatic!

    Oct 14, 2008
    1,634
    224
    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: Apr 13, 2010
  5. CVMichael

    Thread Starter Senior Member

    Aug 3, 2007
    416
    17
    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:
    [​IMG]
     
  6. JDT

    Well-Known Member

    Feb 12, 2009
    658
    85
    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.
     
  7. rjenkins

    AAC Fanatic!

    Nov 6, 2005
    1,015
    69
    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+).
     
  8. CVMichael

    Thread Starter Senior Member

    Aug 3, 2007
    416
    17
    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: Apr 13, 2010
Loading...