Skip to content

This project demonstrates how to interface a 4x4 matrix keypad with an Arduino UNO to read and display key presses on the Serial Monitor.

Notifications You must be signed in to change notification settings

asathiskumar98-byte/4x4-Matrix-Keypad-Interface-with-Arduino

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

🔢 4x4 Matrix Keypad Interface with Arduino

This project demonstrates how to interface a 4x4 matrix keypad with an Arduino UNO to read and display key presses on the Serial Monitor.

🧠 Working Principle

A 4x4 keypad consists of 4 rows and 4 columns (total 16 keys). When a key is pressed, it connects a specific row to a column. The Arduino scans each row sequentially and checks which column input goes LOW — this identifies the pressed key.

🧩 Components Required Component Quantity Arduino UNO 1 4x4 Matrix Keypad 1 Jumper Wires 8 Breadboard 1 USB Cable 1 ⚡ Circuit Connections Keypad Pin Arduino Pin R1 13 R2 12 R3 11 R4 10 C1 9 C2 8 C3 7 C4 6

Columns are set as INPUT_PULLUP and rows as OUTPUT to scan key presses.

💻 Arduino Code

const int C1 = 9;
const int C2 = 8;
const int C3 = 7;
const int C4 = 6;

const int R1 = 13;
const int R2 = 12;
const int R3 = 11;
const int R4 = 10;

void Keypad()
{
  digitalWrite(R1,LOW);
  digitalWrite(R2,HIGH);
  digitalWrite(R3,HIGH);
  digitalWrite(R4,HIGH);
  if(digitalRead(C1) == LOW) { Serial.print('1'); delay(400); }
  if(digitalRead(C2) == LOW) { Serial.print('2'); delay(400); }
  if(digitalRead(C3) == LOW) { Serial.print('3'); delay(400); }
  if(digitalRead(C4) == LOW) { Serial.print('A'); delay(400); }

  digitalWrite(R1,HIGH);
  digitalWrite(R2,LOW);
  digitalWrite(R3,HIGH);
  digitalWrite(R4,HIGH);
  if(digitalRead(C1) == LOW) { Serial.print('4'); delay(400); }
  if(digitalRead(C2) == LOW) { Serial.print('5'); delay(400); }
  if(digitalRead(C3) == LOW) { Serial.print('6'); delay(400); }
  if(digitalRead(C4) == LOW) { Serial.print('B'); delay(400); }

  digitalWrite(R1,HIGH);
  digitalWrite(R2,HIGH);
  digitalWrite(R3,LOW);
  digitalWrite(R4,HIGH);
  if(digitalRead(C1) == LOW) { Serial.print('7'); delay(400); }
  if(digitalRead(C2) == LOW) { Serial.print('8'); delay(400); }
  if(digitalRead(C3) == LOW) { Serial.print('9'); delay(400); }
  if(digitalRead(C4) == LOW) { Serial.print('C'); delay(400); }

  digitalWrite(R1,HIGH);
  digitalWrite(R2,HIGH);
  digitalWrite(R3,HIGH);
  digitalWrite(R4,LOW);
  if(digitalRead(C1) == LOW) { Serial.print('*'); delay(400); }
  if(digitalRead(C2) == LOW) { Serial.print('0'); delay(400); }
  if(digitalRead(C3) == LOW) { Serial.print('#'); delay(400); }
  if(digitalRead(C4) == LOW) { Serial.print('D'); delay(400); }
}

void setup()
{
  pinMode(C1,INPUT_PULLUP);
  pinMode(C2,INPUT_PULLUP);
  pinMode(C3,INPUT_PULLUP);
  pinMode(C4,INPUT_PULLUP);

  pinMode(R1,OUTPUT);
  pinMode(R2,OUTPUT);
  pinMode(R3,OUTPUT);
  pinMode(R4,OUTPUT);

  Serial.begin(9600);
}

void loop()
{
  Keypad(); 
}

🧩 Output

When a key is pressed, the corresponding value (0–9, A–D, *, #) appears in the Serial Monitor at 9600 baud rate.

Example Output:

1 2 3 A 4 5 6 B ...

🚀 How It Works

Arduino sets one row LOW at a time.

It reads the column inputs — if any column reads LOW, that key is pressed.

The program prints the key value to the Serial Monitor.

The scanning repeats continuously to detect any new key press.

🛠️ Applications

Password entry systems

Menu navigation in embedded projects

Home automation input interface

Access control systems

About

This project demonstrates how to interface a 4x4 matrix keypad with an Arduino UNO to read and display key presses on the Serial Monitor.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages