first commit
This commit is contained in:
40
libraries/DS3231/examples/now/now.pde
Normal file
40
libraries/DS3231/examples/now/now.pde
Normal file
@ -0,0 +1,40 @@
|
||||
// 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();
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
Reference in New Issue
Block a user