#include <LiquidCrystal_I2C.h>
#include <DHT.h>
#include <RTClib.h>
#include <LCDBigNumbers.h>
DHT dht(2, DHT22);
LiquidCrystal_I2C lcd(0x27, 20, 4);
RTC_DS1307 rtc;
boolean temp = false;
boolean time = false;
char daysOfTheWeek[7][12] = {"Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"};
void setup() {
Serial.begin(9600);
dht.begin();
lcd.init(); lcd.backlight();
if (! rtc.begin()) {
Serial.println("Couldn't find RTC"); Serial.flush(); abort();
}
pinMode(13,INPUT_PULLUP); pinMode(12,INPUT_PULLUP);
pinMode(11,INPUT_PULLUP); pinMode(10,INPUT_PULLUP);
pinMode(9,INPUT_PULLUP);
}
void loop() {
if(digitalRead(13)==LOW) temp = true;
if(digitalRead(12)==LOW) time = true;
while(temp){
float h = dht.readHumidity(); float t = dht.readTemperature(); float f = dht.readTemperature(true);
float hic = dht.computeHeatIndex(t, h, false);
lcd.print(F("Humidity: ")); lcd.print(h); lcd.print(F(" %")); lcd.setCursor(0,1);
lcd.print(F("Temperature: ")); lcd.print(t); lcd.print(F(" C")); lcd.setCursor(0,2);
lcd.print(F("Heat index: ")); lcd.print(hic); lcd.print(F(" C"));
if(digitalRead(12)==LOW) {time = true; temp = false;}
delay(125);
lcd.clear();
}
while(time){
DateTime now = rtc.now();
lcd.print(now.hour(), DEC); lcd.print(F(":")); lcd.print(now.minute(), DEC); lcd.print(F(":")); lcd.print(now.second(), DEC); lcd.setCursor(0,3);
lcd.print(F("(")); lcd.print(daysOfTheWeek[now.dayOfTheWeek()]); lcd.print(F(") "));
lcd.print(now.year(), DEC); lcd.print(F("/")); lcd.print(now.month(), DEC); lcd.print(F("/")); lcd.print(now.day(), DEC);
delay(125);
if(digitalRead(13)==LOW) {temp = true; time = false;}
lcd.clear();
}
}