#include <DS3231.h>
DS3231 clock;
RTCDateTime robojax;
char daysOfTheWeek[7][12] = {
"Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"};
char monthName[12][12] = {
"January", "February", "March",
"April", "May", "June",
"July", "August", "September",
"October", "November", "December"
};
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup () {
// Robojax Course Lesson 99 video: https://youtu.be/LEQfzmO9Wm0
while (!Serial); // for Leonardo/Micro/Zero
Serial.begin(9600);
// Initialize DS3231
Serial.println("Initialize DS3231");;
clock.begin();
// Set sketch compiling time
clock.setDateTime(__DATE__, __TIME__);
//set manual time
//clock.setDateTime(2014, 4, 13, 19, 21, 00);
// initialize the LCD
//lcd.begin();
lcd.begin(16, 2);
// Turn on the blacklight and print a message.
lcd.backlight();
lcd.print("Robojax");
lcd.setCursor (0,1); // go to start of 2nd line
lcd.print("DS3231 Clock");
}
void loop () {
robojax = clock.getDateTime();
// Robojax Course Lesson 99 video: https://youtu.be/LEQfzmO9Wm0
lcd.clear();
lcd.setCursor (0,0);
lcd.print(robojax.day);
lcd.print(" ");
lcd.print(monthName[robojax.month-1]);
lcd.print(" ");
lcd.print(robojax.year);
lcd.setCursor (0,1); // go to start of 2nd line
lcd.print(robojax.hour);
lcd.print(":");
lcd.print(robojax.minute);
lcd.print(":");
lcd.print(robojax.second);
lcd.print(" ");
lcd.print(daysOfTheWeek[robojax.dayOfWeek]);
delay(300);
// Robojax Course Lesson 99 video: https://youtu.be/LEQfzmO9Wm0
}