#include <DHT.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#define DHTPIN 7
#define DHTTYPE DHT22
LiquidCrystal_I2C lcd (0x27, 16, 2);
DHT dhtku (DHTPIN, DHTTYPE);
int photoPin = A0;
int photoValue = 0;
void setup() {
Serial.begin(9600);
lcd.init();
lcd.backlight();
dhtku.begin();
pinMode(13, OUTPUT); //FAN
pinMode(12, OUTPUT); //PUMP
}
void loop() {
int hum = dhtku.readHumidity();
int temp = dhtku.readTemperature();
photoValue = analogRead(photoPin);
lcd.setCursor(0,0);
lcd.print("Lux:");
lcd.print(photoValue);
lcd.print(" HUM:");
lcd.print(hum);
delay(1000);
lcd.setCursor(0,1);
lcd.print("TEMP:");
lcd.print(temp);
delay(1000);
//----Pengaturan FAN----//
if (temp > 25){
digitalWrite(13, HIGH);
}
else {
digitalWrite(13, LOW);
}
//----Pengaturan PUMP----//
if (hum > 80){
digitalWrite(12, HIGH);
}
else {
digitalWrite(12, LOW);
}
}