#include <RTClib.h>
#define sethr 14
#define setmin 45
#define setsec 10
#define offhr 14
#define offmin 47
#define offsec 10
RTC_DS3231 rtc;
// char daysOfTheWeek[7][12] = {
// "Sunday",
// "Monday",
// "Tuesday",
// "Wednesday",
// "Thursday",
// "Friday",
// "Saturday"
// };
void setup () {
Serial.begin(9600);
// SETUP RTC MODULE
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
Serial.flush();
while (1);
}
// automatically sets the RTC to the date & time on PC this sketch was compiled
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
pinMode(8,OUTPUT);
digitalWrite(8,LOW);
// manually sets the RTC with an explicit date & time, for example to set
// January 21, 2021 at 3am you would call:
// rtc.adjust(DateTime(2021, 1, 21, 3, 0, 0));
}
void loop () {
DateTime now = rtc.now();
// Serial.print("Date & Time: ");
// Serial.print(now.year(), DEC);
// Serial.print('/');
// Serial.print(now.month(), DEC);
// Serial.print('/');
// Serial.print(now.day(), DEC);
// Serial.print(" (");
// Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
// Serial.print(") ");
// Serial.print(now.hour(), DEC);
// Serial.print(':');
// Serial.print(now.minute(), DEC);
// Serial.print(':');
// Serial.println(now.second(), DEC);
if(now.hour()==sethr && now.minute()==setmin && now.second()==setsec)
digitalWrite(8,HIGH);
if(now.hour()==offhr && now.minute()==offmin && now.second()==offsec)
digitalWrite(8,LOW);
delay(1000); // delay 1 seconds
}