Virtuabotixrtc.h Arduino Library (2026)
delay(500);
Serial.println("Time set on RTC.");
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
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.
// Set the time (year, month, day, hour, minute, second, day-of-week) // Sunday = 1, Monday = 2, ..., Saturday = 7 // Example: March 15, 2025, 14:30:00, Saturday = 7 myRTC.setDS1302Time(25, 3, 15, 14, 30, 00, 7); delay(500); Serial
// Turn LED on between 8:00 and 19:59 (8 AM to 7:59 PM) if (currentHour >= 8 && currentHour < 20) digitalWrite(ledPin, HIGH); if (currentHour == 8 && myRTC.minutes == 0 && myRTC.seconds < 5) Serial.println("Good morning! LED is ON.");
#include <VirtuabotixRTC.h> // Pin connections: CLK, DAT, RST VirtuabotixRTC myRTC(6, 7, 8); After running this, comment out myRTC
void loop() // Update the internal variables from the RTC chip myRTC.updateTime();