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);
- Wire.begin();
- // Check if the DS3231 module is connected
- if (!rtc.begin()) {
- Serial.println("Couldn't find RTC");
- while (1);
- }
- // Uncomment the line below to set the time on the DS3231 module
- // rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
- }
- void loop() {
- DateTime now = rtc.now();
- // Print the current date and time
- 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.print(':');
- Serial.print(now.second(), DEC);
- Serial.println();
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement