Using a keypad with Raspberry Pi

I got two keypads from Jameco.com that I wanted to use with my Raspberry Pi. Turns out it's quite easy, as long as you know what the pinout structure is for the keypad.
This instructable will take you through the steps I had to go through to discover the pinout on my keypads, and how I hooked it up to my Raspberry Pi. I'll include the code I'm currently using to β€œdrive” my keypad, and then offer some β€œnext step” type insights into what can be done better, and what could be done next.
Finally, this instructable will really be a sub-instructable that will be part of something I'm calling Voiceberry Pi.Using a keypad with Raspberry Pi

Step 1: Taking a look at what you've got

Because my keypad didn't come with a datasheet of any kind, my first step was to make a visual inspection of the keypads.
So, I took a look at the back, saw that there were 10 wires, and three β€œjumpers” on the outside, but no other indication of how things were wired on the inside. So, I took out the five screws, and looked at the actual circuit board to trace the leads.

Step 2: Tracing the leads

I've got 10 leads, but no idea how they lead to the 12 different buttons. So I have to trace the leads. The images below trace my particular keypad using red lines. Dashed lines follow the jumpers in the back.

Pins are either rows or columns. Rows cover two or more buttons horizontally, and columns cover one or more buttons vertically (even though one key could be a row or a column). Results of tracing are as follows:

Rows: 1,2,3, and 9
Columns: 4,5,6,7,8, and 10
Button- Row – Col
1 – 1 – 5
2 – 1 – 6
3 – 1 – 7
4 – 2 – 5
5 – 2- 6
6 – 2 – 7
7 – 4 – 5
8 – 4 – 6
9 – 3 – 7
0 – 4 – 7
* – 9 – 8
# – 9 – 10Using a keypad with Raspberry Pi schematic

Step 3: Prepping for Prototyping

Now that I knew what it did, I had to make it do it. I desoldered the ribbon cable and installed header pins I scavenged off an old video card. I marked the back of the keypad with the key/pin combinations.
Next I wired it up to the Raspberry Pi. The actual pins you use don't really matter, as you'll include them in the code, which I've attached to this step.
My code includes a list for the rows:
rows=[26,24,23,22,11]
A list for the columns:
cols=[18,16,15,13,7]
And a multidimensional list for the key/button combinations
digits=[[β€œ1β€³,”2β€³,”3”],
[β€œ4β€³,”5β€³,”6”],
[β€œβ€,””,”9β€³],
[β€œ7β€³,”8β€³,”0”],
[β€œβ€,””,””,”*”,”#”]]

For more detail: Using a keypad with Raspberry Pi


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top