#include <Servo.h>
#include <LiquidCrystal.h>
#include<Keypad.h>
Servo myservo;
const int servopin=2;
const int rows =4;
const int columns=4;
char keyss[rows][columns]={
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowpins[rows]={10,9,8,7};
byte colpins[columns]={6,5,4,3};
const int buzzerpin=12;
Keypad keypad=Keypad(makeKeymap(keyss),rowpins,colpins,rows,columns);
LiquidCrystal_I2C lcd(0x27,16,2);
String password="1234";
String inputpassword="";
void setup() {
myservo.attach(servopin);
lcd.init();
lcd.backlight();
myservo.write(0);
lcd.setcursor(0,0);
lcd.print("enter password");
pinMode(buzzerpin, INPUT);
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
char key= Keypad.getkey();
if (key)
{
if (key=="c")
{
if (Unlocked)
{
myservo.write(0);
lcd.clear();
lcd.setcursor(0,0);
lcd.print("Locked");
delay(500);
lcd.clear();
lcd.setcursor(0,0);
lcd.print("eneter password");
}
}
if(key=="*")
{
input password="";
lcd.clear();
lcd.setcursor(0,0);
lcd.print("enter password");
}
if (key=="#")
{
if ( inputpassword== password)
{
myservo.write(90);
lcd.clear();
lcd.setcursor(0,0);
lcd.print("Unlocked");
lcd.print("ENTER C to lock");
}
}else
{
lcd.clear();
lcd.setcursor(0,0)
lcd.print("wrong password");
tone(buzzerpin,1000);
delay(500);
lcd.clear();
lcd.setcursor(0,0);
lcd.print("enter password");
notone(buzzerpin);
}
}inputpassword=""
}