#include <RTClib.h>
RTC_DS1307 rtc;
const char * daysOfTheWeek[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
const byte targetHour = 12;
const byte targetMinute = 50;
const byte targetSecond = 0;
void printTime(DateTime & now, bool nl = false) {
Serial.print(now.hour());
Serial.print(':');
Serial.print(now.minute());
Serial.print(':');
Serial.print(now.second());
if (nl) Serial.println();
}
void setup() {
Serial.begin(115200);
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
Serial.flush();
while (1) delay(10);
}
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
Serial.println("Ready");
}
void loop() {
DateTime now = rtc.now();
DateTime targetTime(now.year(), now.month(), now.day(), targetHour, targetMinute, targetSecond);
Serial.print("Now = "); printTime(now);
Serial.print(" versus target = "); printTime(targetTime, true);
if (now == targetTime) {
Serial.println("Bingo"); // YOU WILL GET MULTIPLE HITS AS LONG AS YOU ARE WITHIN THE TARGET SECOND
}
delay(100);
}