
//www.elegoo.com
//2016.12.
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
DS3231 clock;
RTCDateTime dt;
void setup() {
// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
// lcd.print(“Hello, World!”);
Serial.begin(9600);
Serial.println(“Initialize RTC module”);
// Initialize DS3231
clock.begin();
// Manual (YYYY, MM, DD, HH, II, SS
// clock.setDateTime(2016, 12, 9, 11, 46, 00);
// Send sketch compiling time to Arduino
clock.setDateTime(DATE, TIME);
/*
Tips:This command will be executed every time when Arduino restarts.
Comment this line out to store the memory of DS3231 module
*/
}
void loop() {
dt = clock.getDateTime();
// For leading zero look to DS3231_dateformat example
lcd.setCursor(0,0);
lcd.print(dt.year); lcd.print(“-“);
lcd.print(dt.month); lcd.print(“-“);
lcd.print(dt.day); lcd.print(” “);
lcd.setCursor(0,1);
lcd.print(dt.hour); lcd.print(“:”);
lcd.print(dt.minute); lcd.print(“:”);
lcd.print(dt.second);
delay(1000);
}