# include "DHT.h" //DHT library
# include "LiquidCrystal.h" //lcd library
# define DHTPIN 11 //DHT pin
//Uncomment whichever Type you are using
//# define DHTTYPE DHT11;
# define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE); //Creating DHT object
const int rs = 2, en = 3, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
float t; //temperature in celcius
float h; //humidity in percentage
void setup() //setup
{
Serial.begin(9600);//Setting Boudrate
dht.begin();
lcd.begin(16, 2);// Initializes the interface to the LCD screen
lcd.setCursor(0, 0);
lcd.print(" Selamat Datang ");
lcd.setCursor(0, 1); //Set the location where the text needs to be displayed in LCD
lcd.print(" di D3TT-Telu ");
delay(2000);
lcd.clear();
}
void loop()//loop
{
h = dht.readHumidity() ;
t = dht.readTemperature();
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(t);//Prints the temperature value from the sensor
lcd.print("");
lcd.print((char)223);//shows degrees character
lcd.print("C");
lcd.setCursor(0, 1);
lcd.print("Humi: ");
lcd.print(h);
lcd.print("% ");
delay(5000);
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(dht.convertCtoF(t));//Inbuilt function to convert Temp in Celcius to Fahrenhit
lcd.print(" ");
lcd.print((char)223);//shows degrees character
lcd.print("F");
delay(5000);
}