#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
int switch1 = 7;
int switch2 = 6;
int switch3 = 5;
int switch4 = 4;
int led = 12;
String a;
void setup() {
Serial.begin(9600);
lcd.init();
lcd.backlight();
pinMode(switch1, INPUT);
pinMode(switch2, INPUT);
pinMode(switch3, INPUT);
pinMode(switch4, INPUT);
pinMode(led, OUTPUT);
// put your setup code here, to run once:
}
void loop() {
int push1 = digitalRead(switch1);
int push2 = digitalRead(switch2);
int push3 = digitalRead(switch3);
int push4 = digitalRead(switch4);
if (push1 == 1)
{
a += "O";
delay(1000);
}
if (push2 == 1)
{
a += "P";
delay(1000);
}
if (push3 == 1)
{
a += "E";
delay(1000);
}
if (push4 == 1)
{
a += "N";
delay(1000);
}
if (a.length() >= 4)
{
if (a == "OPEN")
{
digitalWrite(led, HIGH);
lcd.setCursor(0,0);
lcd.print("opened");
Serial.println(a);
delay(10000);
digitalWrite(led, LOW);
delay(10000);
}
else
{
digitalWrite(led, LOW);
lcd.setCursor(0,0);
lcd.print("closed");
delay(1000);
Serial.println("wrong password");
}
}
// put your main code here, to run repeatedly:
}