#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
const byte numRows = 4;
const byte numCols = 4;
char keymap[numRows][numCols] = {
{'1','2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[numRows] = {27, 13, 22, 4};
byte colPins[numCols] = {33, 25, 26, 14};
Keypad keypad = Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
Serial.begin(9600);
Wire.begin(18, 5);
lcd.begin(16, 2);
lcd.home();
lcd.backlight();
lcd.print("sohail");
delay(1000);
lcd.clear();
}
void loop() {
// Read key from keypad
char key = keypad.getKey();
if (key != NO_KEY) {
// Print key to Serial monitor
Serial.println(key);
// Print key to LCD
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(key);
}
}