void setup() Wire.begin(); // Set time once (uncomment and adjust values then upload) // rtc.setDS1307Time(30, 59, 23, 7, 24, 3, 2026); // sec,min,hour,day,date,month,year
The
virtuabotixRTC myRTC(6, 7, 8); const int ledPinRed = 13; const int ledPinGreen = 12; virtuabotixrtc.h arduino library
The library uses a straightforward approach to setting and reading time. You can find the source code and further examples on the ArduinoRTClibrary GitHub repository ArduinoRTClibrary/virtuabotixRTC.h at master - GitHub
// Green LED ON between 07:30 (7:30 AM) and 08:59 (8:59 AM) else if (hour == 7 && minute >= 30 void setup() Wire
void setup() Serial.begin(9600); // myRTC.setDS1302Time(0, 28, 15, 2, 19, 5, 2026); // Uncomment once to set initial time
Note: If you are using a DS1307 or DS3231 module (which have 4 pins: SDA, SCL, VCC, GND), this library will NOT work. You need the Wire.h library or Adafruit RTCLib for those. // Create an instance of the VirtuabotixRTC class
// Create an instance of the VirtuabotixRTC class VirtuabotixRTC myRTC(rtcClockPin, rtcDataPin, rtcCsPin);
: Uses a single execution command to fetch secondary data structures simultaneously, lowering processing overhead.
You can install the VirtuabotixRTC library in two ways: