#include <Wire.h>
#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
const byte key_row = 4;
const byte key_col = 4;
byte row_pins[key_row] = {3, 4, 5, 6};
byte col_pins[key_col] = {8, 9, 10, 11};
char keys[key_row][key_col] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
// Create the Keypad object globally
Keypad keyy = Keypad(makeKeymap(keys), row_pins, col_pins, key_row, key_col);
LiquidCrystal_I2C lcd(0x27, 16, 2); // Adjust the I2C address if necessary
void setup() {
Serial.begin(9600);
lcd.begin(16, 2); // Initialize the LCD with 16 columns and 2 rows
lcd.backlight(); // Turn on the backlight
lcd.print("Ready"); // Initial message
}
void loop() {
char pressedKey = keyy.getKey();
if (pressedKey) { // Check if a key was pressed
Serial.println(pressedKey); // Print the key value
lcd.clear();
lcd.println(pressedKey); // Display the pressed key on the LCD
}
}