// include lib
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
// define lcd
// LCD address: 0x27, 20x4 display
LiquidCrystal_I2C lcd(0x27, 20, 4);
// define DHT22
#define DHTTYPE DHT22
DHT dht(5, DHTTYPE);
void setup() {
lcd.init(); // Initializes the LCD
lcd.backlight(); // Turns on the LCD backlight
dht.begin(); // Initializes communication with the DHT sensor
lcd.setCursor(0, 0); // Sets cursor to the first row
lcd.print("HAZIQ ROHAIZAN"); // Displays your nickname on the LCD
lcd.setCursor(0, 1); // Sets cursor to the second row
lcd.print("Temp: ");
lcd.setCursor(0, 2); // Sets cursor to the third row
lcd.print("Humidity: ");
}
void loop() {
delay(2000); // Delay for sensor reading
// Reads temperature in Celsius
float temperature = dht.readTemperature();
float humidity = dht.readHumidity(); // Reads humidity
lcd.setCursor(7, 1); // Sets cursor to display temperature
lcd.print(temperature);
lcd.print(" C ");
lcd.setCursor(10, 2); // Sets cursor to display humidity
lcd.print(humidity);
lcd.print(" % ");
}