Display current date, hour, second with RTC and LCD Arduino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include <LiquidCrystal_I2C.h> | |
#include <RTClib.h> | |
RTC_DS1307 rtc; | |
LiquidCrystal_I2C lcd(0x27,20,4); | |
void setup() | |
{ | |
lcd.init(); | |
lcd.backlight(); | |
Wire.begin(); | |
rtc.begin(); | |
rtc.adjust(DateTime(F(__DATE__),F(__TIME__))); | |
} | |
void loop() | |
{ | |
DateTime now = rtc.now(); | |
lcd.setCursor(0, 1); | |
// bye default using UTC time | |
// add +7 for your local time | |
lcd.print(now.hour()+7, DEC); | |
lcd.print(':'); | |
lcd.print(now.minute(), DEC); | |
lcd.print(':'); | |
lcd.print(now.second(), DEC); | |
lcd.setCursor(0, 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment