Code:-
#include<LiquidCrystal.h>
#include <DS3231.h>
// Init the DS3231 using the hardware interface
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
DS3231 rtc(SDA, SCL);
void setup()
{ rtc.begin();
lcd.begin(16,2);
// The following lines can be uncommented to set the date and time
rtc.setDOW(WEDNESDAY); // Set Day-of-Week to SUNDAY
rtc.setTime(5, 32, 00); // Set the time to 12:00:00 (24hr format)
rtc.setDate(18, 3, 2020); // Set the date to January 1st, 2014
}
void loop()
{
// Send Day-of-Week
//Serial.print(rtc.getDOWStr());
lcd.print("DATE:");
lcd.print(rtc.getDateStr());
lcd.setCursor(0,2);
lcd.print(rtc.getTimeStr());
lcd.setCursor(9,2);
lcd.print(rtc.getTemp());
lcd.print("*C");
// Send date
//Serial.print(rtc.getDateStr());
//Serial.print(" -- ");
// Send time
//Serial.println(rtc.getTimeStr());
delay(1000);
// Wait one second before repeating :)
}
No comments:
Post a Comment