Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include "RTClib.h"
- RTC_DS1307 rtc;
- //--------------------------------------------------
- void setup () {
- Serial.begin(57600);
- Wire.begin();
- rtc.begin();
- if (! rtc.isrunning())
- {
- Serial.println("RTC is NOT running!");
- rtc.adjust(DateTime(2015,6,8,19,11,55));
- }
- }
- //--------------------------------------------------
- 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.print(':');
- Serial.print(now.second(), DEC);
- Serial.println();
- Serial.print(" since midnight 1/1/1970 = ");
- Serial.print(now.unixtime());
- Serial.print("s = ");
- Serial.print(now.unixtime() / 86400L);
- Serial.println("d");
- delay(3000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement