Contoh Code Sketch untuk LCD matrix I2C dan RTC1307 I2C dipakai bersama .

RTC_LCD_I2C

#include <TimeLib.h>
#include <Wire.h>
#include <DS1307RTC.h> // a basic DS1307 library that returns time as a time_t
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);
tmElements_t tm;
unsigned int counter=0;
void setup() {

lcd.init(); // lcd.begin(16, 2);
lcd.backlight();
lcd.setCursor(0,0); // Set LCD cursor position (column, row)
lcd.print(“DS1307 + LCD-I2C”);
lcd.setCursor(0, 1); // Set LCD cursor position (column, row)
}

void loop()
{
digitalClockDisplay();
}

void digitalClockDisplay()
{
//tmElements_t tm;
if (RTC.read(tm))
{
lcd.setCursor(0, 1); // Set LCD cursor position (column, row)
print2digits(tm.Hour);
lcd.print(“:”);
print2digits(tm.Minute);
lcd.print(“:”);
print2digits(tm.Second);
//lcd.setCursor(4, 2);
print2digits(tm.Day);
lcd.print(“/”);
print2digits(tm.Month);
lcd.print(“/”);
print2digits(tm.Year+1970-2000);
//lcd.setCursor(4, 3);
//lcd.print(tm.Wday);
}

}
//=================
void print2digits(int number)
{
if (number >= 0 && number < 10) {
lcd.print(‘0’);
}
lcd.print(number);
}

/*
void TimeCheck()
{
int tem[17];
for(int i=11;i<17;i++)
{
tem[i]=EEPROM.read(i);
}
if(Hor == tem[11] && Min == tem[12] && off==1)
{
add=11;
lcd.clear();
lcd.print(“alarm………..”);
}
}
*/

Advertisements

About pccontrol

Berisi Tutorial Menggunakan PC untuk mengontrol Peralatan dengan cara mudah & praktis untuk pemula.

Posted on 13/04/2018, in Daftar isi. Bookmark the permalink. Comments Off on Contoh Code Sketch untuk LCD matrix I2C dan RTC1307 I2C dipakai bersama ..

Comments are closed.

%d bloggers like this: