#include "LiquidCrystal_I2C.h"
#include "iarduino_RTC.h"
#include "Wire.h"
const int hour=18;
const int mnt=31;
long laststatC=0;
long past3=0;
char input="Alarm";
int flag =0;
iarduino_RTC time(RTC_DS1307);
#define I2C_ADDR 0x27
#define LCD_COLUMNS 20
#define LCD_LINES 4
LiquidCrystal_I2C lcd(I2C_ADDR, LCD_COLUMNS, LCD_LINES);
void setup() {
// put your setup code here, to run once:
delay(300);
time.begin();
time.settime(0, 30, 18, 12, 6, 20, 5);
lcd.init();
lcd.backlight();
pinMode(7, INPUT);
}
void loop() {
time.gettime();
// put your main code here, to run repeatedly:
lcd.setCursor(0,0);
lcd.print(time.gettime("d M Y, D"));
lcd.setCursor(2,2);
lcd.print(time.gettime("H:i:s"));
if (time.Hours==hour & time.minutes==mnt){
flag=1;
}
delay(1);
if (laststatC==0 & digitalRead(7))//нажали кнопку
{
laststatC = 1;//сменили состояние кнопки
}
long now3 = millis();//использование таймера с периодом 100
if (now3 - past3 >=100)
{
past3 = now3;//сброс таймера
if (laststatC == 1 & !digitalRead(7))//отпустили кнопку
{
flag=0;
}
}
if (flag==1){
lcd.setCursor(3,3);
lcd.print("Alarm");}
else{
lcd.setCursor(3,3);
lcd.print("00000");
}
}