Keypads are widely available and are very reasonably priced. They come in different configurations (4×4, 4×3, etc.) and in many physical sizes . Nearly all electronic suppliers sell them, and you can even get them on Amazon and eBay.
Keypads typically require a lot of pins from the microcontroller to operate, but this board interfaces to keypads with the two pin I²C interface. This project consists of a board that sits on the back of the keypad, and provides two Grove type I²C connectors for easy connection to a microcontroller. This board also has the I²C pullup resistors (enabled with solder jumpers) and jumpers to select the I²C address. The board will operate on either 3.3 or 5 volts. The board only has one chip on it (MCP23008). The total parts cost is under five dollars.
The keypads need to be a “matrix” style keypad, where there is one pin for each row and one pin for each column of keys. For example, a keypad with 4 rows of keys and three columns of keys will have 7 pins on it. When a key is pressed, it produces a shorted connection between the row and column pins. This backpack board will work with keypads that have a maximum of 8 pins (and 16 keys is the maximum supported size, 4×4).
To make it easy to use this board and keypad, I wrote a software library for the Arduino and Particle microcontrollers.
Here are some related projects and posts that might also interest you.
The schematic and pcb layout files (Eagle and pdf) are available at this Github repository.
This project does not require many parts, and most are available from Mouser. Bare PC Boards are available from OSH Park.
|2||J1,J2||4 pin||Grove SMD 90||Seeedstudio.com||320110032|
|1||J3||8 pins||.1 Header Pins||Mouser.com||855-M20-9991645|
|1||J4||2 pins||.1 Header Pins||Mouser.com||855-M20-9991645|
|1||PC Board||OSH Park||Order Link|
You can purchase keypads from many sources including Mouser, Amazon and eBay. The keypad must be a matrix style keypad where this is a pin for each row of keys and a pin for each column of keys.
Bare pc boards are available from OSH Park.
As you probably noticed, this board uses surface mount components, so you will need some skill in dealing with these small parts. Sparkfun has an excellent series of tutorials if you want to brush up your knowledge on soldering these small parts.
Depending on your keypad, you may not need the J3 connector pins, as the backpack board can be soldered directly to a keypad. You probably won’t need J4, unless you are using interrupts to detect when a key is pressed on the keypad. The library routines that I wrote do not use interrupts.
Most keypads have a row of .1 inch spaced pins. Slip the backpack board over this row of pins and solder the board in place.
Using a 4 pin Grove type cable, attach the backpack board to a microcontroller that has a I²C Grove type connector on it. This will power the display and connect the SDA and SCL lines to the microcontroller.
There are five solder jumpers near the center of the backpack board. To “close” a jumper, carefully solder a bridge across the two pads using a small amount of solder.
SJ1, SJ2, and SJ3 control the I²C address of the board. The following table shows the possible address combinations.
If you solder across SJ4 and SJ5 you can enable pull up resistors on the signals SDA and SCL (respectively). At least one pull up resistor is required on these lines somewhere on your various hardware boards.
For Arduino and Particle users, the I2cKeypad library provides functions that make it easy to read the keys as they are pressed on the keypad. An included demo program shows the usage of the functions. These links give the details.
- Information on using the Library
- Github repository for the Arduino software library
- Github repository for the Particle software library
Seeedstudio makes the Particle Photon Base Shield which is a board that allows you to plug in a Particle Photon module. It has the Grove type connectors on it for easy connection to this backpack board.