#include <RTClib.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
RTC_DS1307 rtc;
String text1 = "17:00:00";
int notes[] = {392, 311, 466, 369, 622};
int times[] = {100, 700, 600, 300, 200};
void setup() {
Serial.begin(9600);
Serial.println("17:00:00");
lcd.init();
lcd.backlight();
pinMode(8, OUTPUT);
if (!rtc.begin())
{
while(1);
}
}
void loop() {
DateTime now = rtc.now();
String year, month, day, hour, minute, second;
year = now.year();
month = now.month();
day = now.day();
hour = now.hour();
minute = now.minute();
second = now.second();
String time = "Time: " + hour + ":" + minute + ":" + second;
String timealarm = hour + ":" + minute + ":" + second;
String date = "Date: " + day + "." + month + "." + year;
lcd.setCursor(0, 0);
lcd.print(time);
lcd.setCursor(0, 1);
lcd.print(date);
lcd.setCursor(0, 3);
lcd.print("Created by Yaroslav");
if (Serial.available())
{
String text = Serial.readString();
Serial.println(text);
text1 = text;
Serial.println(text1);
}
if (text1 == timealarm)
{
for (int i = 0; i < 5; i++)
{
tone(8, notes[i], times[i]);
delay(times[i]);
noTone(8);
}
}
delay(1000);
lcd.clear();
}