//Pengaturan Suhu Otomatis - Kelompok 6 TT3B
//Faris Rahman (2103332022)
//Nur Aini (2103332006)
//Yahya Muhaimin(2103332041)
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
DHT dht(DHTPIN, DHTTYPE);
#include <LiquidCrystal.h>
const int rs = 13, en = 11, d4 = 6, d5 = 5, d6 = 4, d7 = 3;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
const int relayPin = 8;
int sensorPin = 2;
void setup() {
dht.begin();
lcd.begin(16,2);
pinMode(relayPin, OUTPUT);
pinMode(sensorPin, INPUT);
Serial.begin(9600);
}
void loop() {
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
// Check if any reads failed and exit early (to try again).
if (isnan(temperature) || isnan(humidity)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
lcd.setCursor(0, 0);
lcd.print("Temp :");
lcd.setCursor(7, 0);
lcd.print(temperature);
lcd.setCursor(12, 0);
lcd.print((char)223);
lcd.setCursor(13, 0);
lcd.print("C");
lcd.setCursor(0, 1);
lcd.print("Humi : ");
lcd.setCursor(7, 1);
lcd.print(humidity);
lcd.setCursor(13, 1);
lcd.print("%");
delay(2000);
lcd.clear();
if (temperature > 28) {
digitalWrite(relayPin, HIGH);
} else {
digitalWrite(relayPin, LOW);
}
}