Virtuabotixrtc.h Arduino Library -
#include <virtuabotixRTC.h> virtuabotixRTC myRTC(7, 6, 5); int alarmPin = 13; // Built-in LED bool alarmTriggered = false;
void loop() // This is the most important line. It reads the RTC's current time // into the library's variables. myRTC.updateTime();
// Set the time and date manually // Syntax: setDS1302Time(seconds, minutes, hours, dayOfMonth, month, dayOfWeek, year) // NOTE: dayOfWeek: Sunday=1, Monday=2 ... Saturday=7 virtuabotixrtc.h arduino library
// --- Different ways to display time ---
void loop() myRTC.updateTime();
// Check if we are within working hours (9 AM to 5 PM) if (myRTC.hours >= 9 && myRTC.hours < 17)
int tempReading = analogRead(tempPin); float voltage = tempReading * (5.0 / 1023.0); float temperatureC = voltage * 100.0; #include <virtuabotixRTC
// 2. Formatted Strings (Best for Serial Monitor) Serial.print("Time (HH:MM:SS): "); Serial.println(myRTC.getTimeStr()); // Returns "14:30:00"