Are you overwhelmed with so many tutorials and guides that take about 4×4 keypad Arduino?
Don’t worry, in this comprehensive guide you will learn everything you need to know about the 4×4 keypad interfacing with Arduino Uno & LCD briefly and to the point. Which includes: code, pinout, schematic, interface, datasheet & fritzing file to download it.
So let’s complete this tutorial to the end to know all the details you need.
Table of Contents
4×4 Keypad
A 4×4 keypad is an input device to determine which key is pressed by the user, it contains 4 rows and 4 columns connected by switches. So when you press any button it will be determined by the intersection of the row and column by the switches between them. Keypads used in many applications: telephones, calculators, and ATMs.

4×4 Keypad Schematic
This 4×4 keypad schematic picture shows all the switches between rows and columns.

There is no connection between each other until you press one of the buttons, which will be determined by the intersection of the row and column.
4×4 Keypad Pinout
4×4 keypad pinout contains 8 pins, 4-row pins which are (R1, R2, R3, R4), and 4-column pins which are (C1, C2, C3, C4).

4×4 Keypad Datasheet
This is a 4×4 keypad datasheet down below, so you can download it.
There is a different datasheet, so take a look at your datasheet from the company you buy it from.
4×4 Keypad Arduino
A 4×4 keypad connects with the Arduino to determine which key is pressed by the user through the intersection of the row and column by the switches between them. Keypads are very important and it is used in many applications:
- telephones
- calculators
- television remotes
- vending machines
- combination locks
- digital door locks
- ATMs
To connect a 4×4 keypad with Arduino follow these steps which will take about in detail:
- Download keypad library
- Connect the 4×4 keypad with Arduino
- Write the code
4×4 Keypad Arduino Library
To install a 4×4 keypad Arduino library follow these steps:
- At the Arduino IDE, click Sketch->Include Library->Manage Libraries…

- Type ‘Keypad’ in the search tab then go to Keypad by Mark Stanley, Alexander Brevig, you have to scroll down to find it.
- Click Install and wait for a few seconds and it will download it.

4×4 Keypad Interfacing With Arduino Uno
To connect the 4×4 keypad to Arduino, you need to interface 4-row pins in the keypad which are (R1, R2, R3, R4) with the Arduino digital pins (9, 8, 7, 6), and the 4-column pins which are (C1, C2, C3, C4) with Arduino digital pins (5, 4, 3, 2).
The picture down below shows the connection in detail.

Parts Requirement:
- Arduino Uno
- 4×4 membrane keypad
- Hook-up wires
4×4 Keypad and LCD Interfacing With Arduino Uno
Let’s dive into the connection between the keypad and LCD with Arduino, also we will provide you the code and connection file in fritzing software.
The picture down below shows the connection in detail.
If you need to learn more about 16×2 LCD you can read this blog 16×2 LCD Interfacing With Arduino.

Parts Requirement:
- Arduino Uno
- 16×2 LCD Screen
- 4×4 membrane keypad
- Breadboard
- Hook-up wires
- 250k ohm potentiometer
- 220-ohm resistor
4×4 Keypad Fritzing
These are the fritzing files for the two connections that you learned in this tutorial.
fritzing keypad 4×4 download
- 4×4 keypad interfacing with Arduino Uno fritzing files
- 4×4 keypad and LCD interfacing with Arduino Uno fritzing files
Keypad Arduino code
These are the codes for the two connections that you learned:
- 4×4 keypad Arduino code
- Arduino keypad 4×4 LCD code
4×4 Keypad Arduino Code
This 4×4 keypad Arduino code down below will print any key you pressed in the serial monitor.
#include <Keypad.h>
const byte ROWS = 4; //the four rows of the keypad
const byte COLS = 4; //the four columns of the keypad
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6}; //to connect to the row pins of the keypad
byte colPins[COLS] = {5, 4, 3, 2}; //to connect to the column pins of the keypad
//Create the keypad as an object
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup(){
Serial.begin(9600);
}
void loop(){
char key = keypad.getKey();// Read the key
// Print the key if pressed
if (key){
Serial.print("Key Pressed : ");
Serial.println(key);
}
}
Arduino Keypad 4×4 LCD Code
This Arduino Keypad 4×4 LCD code down below will print any key you pressed in 16×2 LCD.
#include <Keypad.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(5, 4, 3, 2, A4, A5);
const byte ROWS = 4; //the four rows of the keypad
const byte COLS = 4; //the four columns of the keypad
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {A0, A1, 11, 10}; //to connect to the row pins of the keypad
byte colPins[COLS] = {9, 8, 7, 6}; //to connect to the column pins of the keypad
int LCDCol = 0;
int LCDRow = 0;
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup(){
Serial.begin(9600);
lcd.begin(16, 2);
lcd.setCursor(LCDCol, LCDRow);
}
void loop(){
char key = keypad.getKey();
if (key){
Serial.println(key);
if ( LCDCol > 15 )
{
++LCDRow;
if (LCDRow>1)
{ LCDRow=0; LCDCol = 0 ; lcd.clear(); }
LCDCol = 0 ;
}
lcd.setCursor (LCDCol, LCDRow);
lcd.print(key);
++LCDCol;
}
}
Frequently Asked Questions
What is 4×4 keypad Arduino?
A 4×4 keypad is an input device to determine which key is pressed by the user by processing it on the Arduino, it contains 4 rows and 4 columns connected by switches. So when you press any button it will be determined by the intersection of the row and column by the switches between them. Keypads used in many applications: telephones, calculators, and ATMs.
How many keys are in 4×4 matrix keypad?
The 4×4 matrix keypad has 16 keys which are: (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, *, #).
How to connect 4×4 keypad to Arduino?
To connect the 4×4 keypad to Arduino, you need to interface 4-row pins in the keypad which are (R1, R2, R3, R4) with the Arduino digital pins (9, 8, 7, 6), and the 4-column pins which are (C1, C2, C3, C4) with Arduino digital pins (5, 4, 3, 2).
How do I add a library keypad to Arduino?
To add the Keypad library, in the Arduino IDE, go to Sketch->Include Library->Manage Libraries then type ‘Keypad‘ in the search tab and chose Keypad by Mark Stanley, Alexander Brevig, and then click install.
What library is needed to use a keypad in Arduino?
The library you needed is Keypad by Mark Stanley, Alexander Brevig, you can find it by typing’ Keypad’ in the search tab and scrolling down.
Thank you to being with us until the end of this tutorial and I hope you find what you need about 4×4 keypad Arduino, if your passion about Arduino and want to learn more.
ROBOSANS is the best place to learn about Arduino with a brief tutorial and to the point.
If you want to learn more, read these articles down below.
Interfacing 7 Segment Display with Arduino
16×2 LCD Interfacing with Arduino
Sources: