//deklarasi
#include <Servo.h>
#include <DHT.h>
#include <LiquidCrystal_I2C.h>
#define DHTPIN 8
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27, 16,2);
Servo myservo;
int pos = 0;
void setup() {
// put your setup code here, to run once:
myservo.attach(11);
Serial.begin(115200);
Serial.println("SUHU DAN KELEMBABAN");
dht.begin();
lcd.init();
lcd.backlight();
lcd.setCursor(1,0);
lcd.print("SELAMAT DATANG");
lcd.setCursor(3,1);
lcd.print("SYIHABUDIN");
delay(1000);
}
void loop() {
// put your main code here, to run repeatedly:
myservo.attach(11);
float h = dht.readHumidity();
float t = dht.readTemperature();
Serial.print("Kelembaban: ");
Serial.print(h);
Serial.print("% Temperature: ");
Serial.print(t);
Serial.print("°C ");
if(t > 40){
myservo.write(180);
Serial.println(pos);
delay(1000);
delay(1000);
myservo.write(0);
Serial.println(pos);
delay(1000);
}
else{
myservo.detach();
}
lcd.setCursor(0,0);
lcd.print("Suhu : ");
lcd.print(t);
lcd.print(" C");
delay(100);
lcd.setCursor(0,1);
lcd.print("Lembab : ");
lcd.print(h);
lcd.print(" %");
delay(100);
}