Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I have 8pin 4x4 keyapd, and i want to connect it to my microcontroller, I've search over the net but i can't see its pin configuration. I have a problem connecting it because of that can someone help me. I have a picture of the keypad and pin description of my controller here.pi description

enter image description here

share|improve this question
possible duplicate of Seeking 4x3 keypad for Atmel UC3 microprocessor –  Ignacio Vazquez-Abrams Jan 13 at 10:17
You need connect to any Digital I/O port. –  Butzke Jan 13 at 10:17
It's not a duplicate question, btw, I have searched what i am looking for over the net. thanks for you answers. –  NewInEverything Jan 13 at 10:23
You should double-check the results using the techniques in the answers, but it looks to me a lot like the one Parallax and others sell parallax.com/sites/default/files/downloads/… –  PeterJ Jan 13 at 10:41
add comment

3 Answers

up vote 2 down vote accepted

Here is a relevant guide

enter image description here

Keypad Pin  Connects to Arduino Pin...
1           D9
2           D8
3           D7
4           D6
5           D5
6           D4
7           D3
8           D2

enter image description here

/*4x4 Matrix Keypad connected to Arduino
This code prints the key pressed on the keypad to the serial port*/

#include <Keypad.h>

const byte numRows= 4; //number of rows on the keypad
const byte numCols= 4; //number of columns on the keypad

//keymap defines the key pressed according to the row and columns just as appears on the keypad
char keymap[numRows][numCols]=
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}

//Code that shows the the keypad connections to the arduino terminals
byte rowPins[numRows] = {9,8,7,6}; //Rows 0 to 3
byte colPins[numCols]= {5,4,3,2}; //Columns 0 to 3

//initializes an instance of the Keypad class
Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);

void setup()

//If key is pressed, this key is stored in 'keypressed' variable
//If key is not equal to 'NO_KEY', then this key is printed out
//if count=17, then count is reset back to 0 (this means no key is pressed during the whole keypad scan process
void loop()
char keypressed = myKeypad.getKey();
if (keypressed != NO_KEY)
share|improve this answer
this connection is using parallel communication right? Can I have it's output on a lcd using serial communication? –  NewInEverything Jan 13 at 10:40
@NewInEverything All the pins of the matrix need to be connected in order for the keyboard scan to work properly. The example code just outputs the result using the serial port (to a terminal) but you can modify the code to show the result to a display. –  alexan_e Jan 13 at 10:49
so I can only see the output in the serial monitor? –  NewInEverything Jan 13 at 10:51
@NewInEverything Yes, read the comment of the code for the last part –  alexan_e Jan 13 at 10:57
@NewInEverything keypressed variable contains the read value as a char, after checking that a button has been pressed (if (keypressed != NO_KEY)) you can use the value whenever you want, but if you need an integer you have to convert it. For characters "0"-"9" to be converted to integers you just need to subtract decimal 48 (that is 0x30 as hex) –  alexan_e Jan 14 at 9:39
show 13 more comments

I've search over the net but i can't see its pin configuration.

I assume I'm seeing an 8 wire tail.
Maybe 9. Just maybe 7.

The keypad is likely to have the connections brought out as 4 rows and 4 columns. If there is a 9th wire it may be a shield.

Use an Ohm meter set to say something like 100k (or 199.9k or whatever) range. This allows you to not miss very high resistance contacts. A 20k range MAY be OK but 200k is safer.

Make contact with conductive end of tail with meter probes. Try putting 2 probes on the same tail and ensure you can easily see the meter respond - most tails will be insulated until near the end and some may be oxidised on the conductive surfaces and need a CAREFUL rub with the meter probe tip to make contact. Tails may be made by depositing conductive ink so will usually not be super strong so use reasonable care when making contact. They are usually not super delicate - just be sensible.

IF you have a connector for the keyboard, use it. I'll assume 8 conductors numbered 1 to 8 below. Adjust as needed.

Having an assistant is not essential but helps.
Hold down one key and place one probe on contact 1 (1st wire) and go along all other wires 2-8 with probe to see if a contact can be found.
If not, place one probe on 2nd wire (contact 2) and go along 3-8. Then
3 + 4-8
4 + 5-8
5 + 6-8
6 + 7-8
7 + 8

If you do not get a contact closure on ANY of the above then you are not making proper contact (most likely) or the keyboard is dead (less likely).

Record the result and try another key.

After a few tries a pattern will appear. Probably 4 x row and 4 x column as above.

An alternative method is to choose two contacts for meter probes and press keys in turn until a closure occurs eg contacts on 2 + 5 MAY respond to key 4. (2nd row, 5-4 = 1 = 1st column) but may not.

This method MUST work if done properly if the matrix has only switches.

SOME keyboards have internal diodes but this is extremely unlikely for your keyboard. For keyboards with diodes, meter polarity matters.

Kayboards that look very like yours can be found at:

Here - see below

enter image description here

And here for $6.99 - same arrangement.
Manufacturer: Parallax
Product Code: Dev-4x4Key-01

Maybe herefor $ less.


enter image description here

share|improve this answer
add comment

Figuring out the matrix wiring of the 4x4 keypad is dead simple with an ohm meter. Attach the meter leads to selected pairs of the conductors in the connection cable. Then press the buttons one at a time to see which switch closes the connection between the selected conductors. If you write down the connection numbers as 1 to 8 and then make a table of the selected pairs in sequence and which switch closes each pair. Some pairs will not cause any closures to be registered. When this happens you will know that the selected pair of connection wires are either both row wires in the switch matrix or column wires.

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.