Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include "RTClib.h"
- RTC_DS3231 rtc;
- void setup() {
- Serial.begin(9600);
- rtc.begin();
- if (rtc.lostPower()) {
- rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
- }
- }
- void loop() {
- DateTime now = rtc.now();
- Serial.print(now.year(), DEC);
- Serial.print('/');
- Serial.print(now.month(), DEC);
- Serial.print('/');
- Serial.print(now.day(), DEC);
- Serial.print(" ");
- Serial.print(now.hour(), DEC);
- Serial.print(':');
- Serial.print(now.minute(), DEC);
- Serial.println();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement