Analog 12 Button Keypad

Contents:

Overview

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.

Back of the keypad

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.

Demo

More to come…

Schematic:

Parts List

PartQuantityPurpose
Momentary Pushbutton12Takes user input. These are the keys of the keypad
10K Resistor11Makes up the voltage divider that determines the voltage read by the microntroller it's connected to.
2-pin male right-angle header1Provides an output and ground connection to a microntroller or other device.
2" x 2 1/4" proto board1Makes everything nice and organized.

The Code

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

Save