top of page

4*4 Keypad Interfacing with Arduino UNO.

What is a 4*4 Keypad?


In embedded devices one of the essential parts is Keypad is used to interact with embedded devices, Keypad is an input device that is used to give the command to the devices, from the calculator to the computer input is given through the keypad. 4×4 Matrix Keypad and how the Arduino Keypad Interface works. A Keypad is an input device that is used to enter passwords, dial a number, browse through the menu and even control robots.


Material Required:


Material Quantity


Arduino Uno 1

4*4 Keypad 1

Jumper cables 8



Pinout Diagram:


If you have a keypad look for one below. The below diagram is enough for knowing pin configuration.




Circuit Diagram:


Follow the given pin order for wiring the circuit. As shown in the left diagram. Start from left to right.



Keypad Pin 1 (R4) –> Arduino Pin 2

Keypad Pin 2 (R3) –> Arduino Pin 3

Keypad Pin 3 (R2) –> Arduino Pin 4

Keypad Pin 5 (C4) –> Arduino Pin 6

Keypad Pin 6 (C3) –> Arduino Pin 7

Keypad Pin 7 (C2) –> Arduino Pin 8

Keypad Pin 8 (C1) –> Arduino Pin 9




Tested Programming Code:


/* ##### 4x4 Membrane Keypad Arduino Interfacing #####Arduino and Keypad Connection

Keypad Pin => Arduino Pin

1 => Digital Pin 2

2 => Digital Pin 3

3 => Digital Pin 4

4 => Digital Pin 5

5 => Digital Pin 6

6 => Digital Pin 7

7 => Digital Pin 8

8 => Digital Pin 9*


#include <Keypad.h>

const byte ROWS = 4; //four rows

const byte COLS = 4; //four columns

// Define the Keymap

char hexaKeys[ROWS][COLS] = {

{'1','2','3','A'},

{'4','5','6','B'},

{'7','8','9','C'},

{'*','0','#','D'}

};

byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the Rows of the keypad pin 8, 7, 6, 5 respectively

byte colPins[COLS] = {5, 4, 3, 2}; //connect to the Columns of the keypad pin 4, 3, 2, 1 respectively

//initialize an instance of class NewKeypad

Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup(){

Serial.begin(9600);

}

void loop(){

char customKey = customKeypad.getKey();

if (customKey){

Serial.println(customKey); // Send the pressed key value to the arduino serial monitor

}

}


Checking Values on Serial Monitor:


After successfully uploading the Program to the Arduino Board, You can check the input given through the keypad on the Serial monitor.




Precautions:


1. Double-check the connections before powering on the circuit.

2. Don’t use loose jumper cables.

3. Check whether the proper board is selected from Arduino IDE.

4. Ensure proper placement of sensor for correct working.

5. Connect the Wiper pin of the potentiometer correctly.

6. Don’t lose hope if Keypad does not run properly for the first time, try again


Conclusion:


You can successfully display inputs given in the keypad on the Serial Monitor in the simplest way using Arduino.

GET IN TOUCH

We'd love to hear from you

bottom of page