/*
author : Rajeev TR
date : 30/08/2024
https://github.com/HoNtErBoT
*/
#include <Keypad.h>
// Define the number of rows and columns on the keypad
const byte ROWS = 4;
const byte COLS = 4;
// Define the keymap for your keypad
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {2, 3, 4, 5}; // Connect keypad ROW0, ROW1, ROW2, ROW3 to Arduino pins 2, 3, 4, 5
byte colPins[COLS] = {6, 7, 8, 9}; // Connect keypad COL0, COL1, COL2, COL3 to Arduino pins 6, 7, 8, 9
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS); // Create the Keypad object
void setup()
{
Serial.begin(9600); // Initialize the serial communication
}
void loop()
{
char key = keypad.getKey(); // Read the key
if (key)
{
Serial.println(key); // Print the key pressed to the serial monitor
}
}