#include <LiquidCrystal_I2C.h>
#include<Keypad.h>
LiquidCrystal_I2C lcd(0x27,16,4);
//Define collumn and row
const byte ROWS = 4;
const byte COLS = 4;
//Define the key map
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'},
};
// Connect to the row pinouts of the keypad
byte rowPins[ROWS] = {9, 8, 7, 6};
// Connect to the column pinouts of the keypad
byte colPins[COLS] = {5, 4, 3, 2};
//Create the keypad bjects
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
//Set password
String correctPassword = "2708";
String enteredPassword = ""
void setup (){
//Turn on LCD
lcd.init();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("Enter Your Password");}
void loop (){
char key = keypad.getKey(); // Read the key
if(key){
if(key == '#''){
if (enteredPassword == correctPassword){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Access Granted");}
else{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Access Denied");
}
}