Introduction: Arduino 16x2 LCD Display and 4x4 Matrix Keypad

In Embedded system design, matrix keypad (4x4, 4x3, 3x3 or 5x5) is used for key in the user inputs. Similarly character LCD display [16x2, 16x4, 20x2 or 20x4 LCDs] is used for indicating the system status / parameters. This intractable is about interfacing 16×2 LCD and 4x4 matrix keypad with Arduino microcontroller.

Parts and components

  • Arduino Uno board
  • 16x2 LCD
  • 1 K ohm potentiometer
  • 4x4 matrix keypad

Step 1: Schematic

  • The 16x2 is very common type LCD, with two rows, and each row displays 16 characters of either 5x7 or 5x8 dot matrix characters.
  • The LCD is available in a 16 pin package. It consists of back light and contrast adjustment function and each dot matrix has 5×8 dot resolution.
  • The 16x2 LCD display is connected to the Arduino (A0,A1,A2,A3,A4,A5) analog IO pins, where those pins are configured as digital in / out, where LCD operates at 4 bit data mode.
  • If the display is not visible, adjust the Contrast pot (1K), to make it visible.
  • Matrix key pad is arranged by push button switches in rows and columns.

  • In a simple technique, the 16 keys of matrix keypad is connected with 8 digital IOpins of Arduino.

  • Usually the keypad scan procedure is

  • The key is decoded through Column selection / Row read.

  • Write HIGH to Column One. And keep rest of the Column to LOW.

  • Scan (Read) the Row One to Row Four, to find the key.

  • Repeat until a key press (are multiple) is identified.

  • The Row pins are connected to 5,4,3 and 2nd digital IO pins of Arduino.

  • The Column pins are connected to 6,7,8 and 9th digital IO pins of Arduino.

Step 2: Software

  • The Arduino LiquidCrystal and Keypad library is used for displaying the status and detecting key press.
  • The LCD displays the “KEYPAD LCD TEST” as welcome screen at the first line
  • Number of seconds since start “SEC= 123” is displayed at the second line column one.
  • The detected key is displayed at (“KEY= 5”) second line column 9 on wards.

Demonstrates the use a 16x2 LCD display and 4x4 LCD display. T

The Arduino circuit connection for LCD:

* LCD RS pin to analog pin A0

* LCD Enable pin to analog pin A1

* LCD D4 pin to analog pin A2

* LCD D5 pin to analog pin A3

* LCD D6 pin to analog pin A4

* LCD D7 pin to analog pin A5

The Arduino circuit connection for MAtrix Key Pad:

* ROW1 pin to digital pin 5

* ROW2 pin to digital pin 4

* ROW3 pin to digital pin 3

* ROW4 pin to digital pin 2

* COLUMN1 pin to digital pin 6

* COLUMN2 pin to digital pin 7

* COLUMN3 pin to digital pin 8

* COLUMN4 pin to digital pin 9

Name:- M.Pugazhendi

Date:- 04thJul2016

Version:- V0.1



// include the library code:



//initialize the library with the numbers of the interface pins

LiquidCrystal lcd(A0,A1,A2,A3,A4,A5);

//4x4 Matrix key pad

const byte ROWS = 4; // Four rows

const byte COLS = 4; // Four columns

// Define the Keymap

char keys[ROWS][COLS] =







// Connect keypad ROW0, ROW1, ROW2 and ROW3 to Arduino pins.

byte rowPins[ROWS] = { 5, 4, 3, 2 };

// Connect keypad COL0, COL1, COL2 and COL3 to Arduino pins.

byte colPins[COLS] = { 6, 7, 8, 9 };

// Create the Keypad

Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup()


// set up the LCD's number of columns and rows:

lcd.begin(16, 2);

// Print a message to the LCD.

lcd.print("KEYPAD LCD TEST");


void loop()


char key = kpd.getKey();

// set the cursor to column 0, line 1

// (note: line 1 is the second row, since counting begins with 0):

lcd.setCursor(0, 1);

// print the number of seconds since reset:

lcd.print("SEC= ");

lcd.print(millis() / 1000);

// Check for a valid key



// set the cursor to column 9, line 1

// (note: line 1 is the second row, since counting begins with 0):

lcd.setCursor(9, 1);

//Print the detected key

lcd.print("KEY= ");





  • The project is successfully simulated by using the Proteus.
  • The Keypad and LCD display can be used for many embedded projects as user input and status display.


BilalS14 (author)2017-03-11

Alhamdulliha! doing work.....

RegsterU (author)2017-02-26

bad instruction

yohanes.trilaksono (author)2017-02-25


About This Instructable




More by PugazhM:Arduino and ENC28J60 Ethernet Controller, (320x480) TFT LCD, DHT22 Temperature / Humidity Web ServerArduino and Infra-Red (IR) Obstacle Detection / Proximity Sensing / Line Counter, With 320x480 LCD InterfaceArduino and 3.5 Inch (320x480) TFT LCD (ILI9488) SPI Interface With DHT22 Temperature / Humidity Measurement
Add instructable to: