3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Arduino 3 wire Matrix Keypad

Arduino 3 wire Matrix Keypad

Keypad connected with only 3 wires to Arduino.

Background:

A matrix keypad can be connected to an Arduino board so that numerical data can be entered by the user.
Instructions exist in various forums on how to do this. The main problem is that this usually uses up a total of 7 of your digital input/output pins.

The problem:
For me this is a big problem as I want these pins free to control external devices such as solenoid valves and actuators. I also need some to send data to a serial LCD display.

Options are either
a) Use an Arduino Mega with lots more pins or
b) Find a way of interfacing a keypad using less input pins.

Solution:
By using ONE single analog input pin and a grid of resistors, we can wire up the buttons on the keypad such that when each is pressed a different voltage is sent to the analog input pin.

Although it is a hassle wiring up all the resistors, the big advantage is that all your digital pins remain free to be used for other things.

This has been described before on AVR forums but I have adapted it for Arduino and written some code for you to get started.






 

 
Remove these adsRemove these ads by Signing Up
 

Step 1Identify the keypad pins

Identify the keypad pins
On base of keypad are 7 solder terminals.

Keypad can be considered to have 3 "columns" and 4 "rows" - see photo.

First step is to work out which solder terminal represents each row and which represents each column. Write everything down as you go along, very easy to mix everything up.

This has been described and you need to follow the instructions on how to do this given in this Arduino keypad tutorial:

http://www.arduino.cc/playground/Main/KeypadTutorial

« Previous StepDownload PDFView All StepsNext Step »
14 comments
Feb 29, 2012. 4:35 AMroachburn says:
How do i get it to display the * or the # signs?
Jul 2, 2011. 12:23 PMDominion-Network says:
Has anyone actually done this? I'd love to see pictures of the end result.
Jun 3, 2011. 12:33 PMthiagottjv says:
Can i use another capacitor size? like a 100nf?
And the resistors? how did you calculate the sizes?
Feb 13, 2011. 11:32 AMData643 says:
The keypad in the picture is not the keypad you describe. You say it has 7 pins. The one in the picture has 14.
Jun 28, 2011. 12:37 PMbudabob07 says:
Very clever. Great way to save pins without using shift registers or other IC's
Jan 10, 2011. 12:26 AMfennecfanatic says:
Wouldn't it be a lot simpler to do this with a parallel-in shift register? That would only use three pins, and you could do the same thing with parallel-out regs for outputs. Granted, it would cost a little more.
Aug 16, 2010. 2:19 AMyes8s says:
There is an error with your diagram above. The "1500 Ohm" resistor should actually be "15000 Ohm".
Jul 25, 2010. 10:18 AMdoby162 says:
I thought about doing this before. I guess since the keypad was only going to be for one project and it only needed a couple other pins I just took the lasy way out =). Well implemented though, I definantly think this shouldev been featured.
Jul 18, 2010. 8:18 AMnadav says:
WOW! how this didnt get featured is beyond me... Great 'ible thanks. -Nadav
Jul 18, 2010. 5:07 PMnadav says:
yeah, i always like to think ahead just incase there are upgrades to the project im doing. especially if its going to be permanent..

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
125
Followers
10
Author:XenonJohn