Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // now.pde
- // Prints a snapshot of the current date and time along with the UNIX time
- // Modified by Andy Wickert from the JeeLabs / Ladyada RTC library examples
- // 5/15/11
- #include <Wire.h>
- #include <DS3231.h>
- RTClib myRTC;
- void setup () {
- Serial.begin(57600);
- Wire.begin();
- delay(500);
- Serial.println("Nano Ready!");
- }
- void loop () {
- delay(1000);
- DateTime now = myRTC.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");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement