#include <LiquidCrystal.h>
#include<EEPROM.h>
//-----------------------------------//
//settings
//-----------------------------------//
int minute = 1;
//-----------------------------------//
const int rs = 7, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
const int stsp = A0;
const int buzz = 9;
const int relay = 8;
int Min = 0;
int sec = 0;
unsigned int check_val = 50;
bool RUN = true;
bool min_flag = true;
void setup()
{
lcd.begin(16, 2);
pinMode(stsp, INPUT_PULLUP);
pinMode(buzz, OUTPUT);
pinMode(relay, OUTPUT);
digitalWrite(relay, LOW);
digitalWrite(buzz, LOW);
Min = minute;
delay(1500);
INIT();
}
void loop()
{
if (digitalRead(stsp) == LOW)
{
lcd.clear();
delay(250);
RUN = true;
while (RUN)
{
if (digitalRead(stsp) == LOW)
digitalWrite(relay, HIGH);
sec = sec - 1;
delay(1000);
if (sec == -1)
{
sec = 59;
Min = Min - 1;
}
lcd.setCursor(1, 0);
lcd.print("Enter Password");
lcd.setCursor(5, 1);
//lcd.print(':');
if (Min <= 9)
{
lcd.print('0');
}
lcd.print(Min);
lcd.print(':');
if (sec <= 9)
{
lcd.print('0');
}
lcd.print(sec);
if (Min == 0 && sec == 0)
{
digitalWrite(relay, LOW);
lcd.setCursor(4, 0);
RUN = false;
for (int i = 0; i < 20; i++)
{
/*digitalWrite(buzz, HIGH);
delay(100);
digitalWrite(buzz, LOW);
delay(100);*/
boom();
}
//INIT();
}
}
}
}
void INIT()
{
Min = minute;
sec = 0;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Start / Set Time");
lcd.setCursor(5, 1);
if (Min <= 9)
{
lcd.print('0');
}
lcd.print(Min);
lcd.print(':');
if (sec <= 9)
{
lcd.print('0');
}
lcd.print(sec);
min_flag = true;
delay(500);
}
void boom()
{
digitalWrite(buzz, HIGH);
delay(250);
digitalWrite(buzz, LOW);
delay(250);
boom();
}