Virtuabotixrtc.h Arduino Library -
A minimal example to set and print time:
#include // Creation of the Real Time Clock Object (CLK, DAT, RST) virtuabotixRTC myRTC(6, 7, 8); void setup() Serial.begin(9600); // Set time only on the first run: sec, min, hr, dow, day, month, year myRTC.setDS1302Time(00, 30, 15, 4, 16, 4, 2026); void loop() myRTC.updateTime(); // Pull latest data from the chip Serial.print("Current Date / Time: "); Serial.print(myRTC.dayofmonth); Serial.print("/"); Serial.print(myRTC.month); Serial.print("/"); Serial.print(myRTC.year); Serial.print(" "); Serial.print(myRTC.hours); Serial.print(":"); Serial.println(myRTC.minutes); delay(1000); Use code with caution. Copied to clipboard Installation and Availability virtuabotixrtc.h arduino library
virtuabotixRTC.h library is a specialized tool for Arduino users to interface with DS1302 Real-Time Clock (RTC) A minimal example to set and print time:
Let's tie everything together with a practical project. This code will turn on an LED (or relay) at a specific time. void setup() Serial
void setup() Serial.begin(9600); // Uncomment to set time (year, month, date, hour, minute, second, dayOfWeek) // myRTC.setDS1302Time(0, 27, 13, 4, 11, 4, 2026); // Example: 2026-04-11 13:27:00 Sat