This little 12-button keypad uses just one analog microcontroller input pin and a ground connection. It’s basically a bunch of voltage dividers daisy-chained together. Pushing a button gives a different voltage value at the positive (+) pin which can be read by the microcontroller’s analog pin. I’ve only tested this with an Arduino-compatible board, but see no reason why it wouldn’t work with something else.
I’ve managed to fit this on a 2″ x 2 1/4″ piece of proto-board. This was a pain to solder by hand, but the small footprint was worth it. I’m not too crazy about the use of all of these solder bridges, but it works. Maybe one day I’ll create an actual PCB board layout so this can more easily be replicated. I had to reflow a few of the connections to make the keypad more reliable, being careful not to lift the copper pads (only two were lost, thankfully). With this many small solder joints so close together, lousy connections happen.
More to come…
|Momentary Pushbutton||12||Takes user input. These are the keys of the keypad|
|10K Resistor||11||Makes up the voltage divider that determines the voltage read by the microntroller it's connected to.|
|2-pin male right-angle header||1||Provides an output and ground connection to a microntroller or other device.|
|2" x 2 1/4" proto board||1||Makes everything nice and organized.|
From a software side, the two main things to consider are button debouncing and the mapping of ADC values read from the analog pin to the buttons themselves. There’s a high and low ADC value (giving a range) for each button. I wrote an Arduino library to handle that.
The Arduino library maps the ADC ranges to button values 1 through 12 internally, but you can label the buttons any way you like. As long as the code can differentiate between the button presses, it doesn’t matter what you call the buttons.
The code for the library can be found on github: https://github.com/upperboundcom/AnalogKeypad