// Print the current date and time Serial.print(currentTime.year); Serial.print("-"); Serial.print(currentTime.month); Serial.print("-"); Serial.print(currentTime.day); Serial.print(" "); Serial.print(currentTime.hour); Serial.print(":"); Serial.print(currentTime.minute); Serial.print(":"); Serial.println(currentTime.second);
Here is an example of how to use the Virtuabotix RTC Arduino Library to set the current date and time:
void loop() { // Get the current date and time DateTime currentTime = myRTC.getDS1302Time(); virtuabotixrtch arduino library
// Set the current date and time myRTC.setDS1302Time(0, 0, 0, 1, 1, 2023, 0); }
// Create an instance of the VirtuabotixRTC class VirtuabotixRTC myRTC(rtcClockPin, rtcDataPin, rtcRstPin); // Print the current date and time Serial
void setup() { // Initialize the RTC module myRTC.begin();
#include <VirtuabotixRTC.h>
delay(1000); }