else digitalWrite(ledPin, LOW); if (currentHour == 20 && myRTC.minutes == 0 && myRTC.seconds < 5) Serial.println("Evening – LED is OFF.");
void loop() myRTC.updateTime();
Serial.println("Time set on RTC.");
After running this, comment out myRTC.setDS1302Time(...) or upload a new sketch that only reads time. Example 2: Reading the Current Time Here’s the most common use: continuously reading the RTC and printing to Serial Monitor.
Open the Serial Monitor (9600 baud) and watch the live clock. This is where the RTC shines. Let’s turn an LED on at 8:00 AM and off at 8:00 PM. virtuabotixrtc.h arduino library
delay(1000); // Update every second
int currentHour = myRTC.hours;
void loop() // Update the internal variables from the RTC chip myRTC.updateTime();