#include <DHT.h>
#include <LiquidCrystal.h>
#define DHT_PIN 2 // Pin to which DHT22 sensor is connected
#define BUZZER_PIN 7 // Pin to which the buzzer is connected
#define DHT_TYPE DHT22 // Change to DHT11 if using DHT11 sensor
DHT dht(DHT_PIN, DHT_TYPE);
LiquidCrystal lcd(8, 9, 10, 11, 12, 13); // Pins for the LCD: RS, E, D4, D5, D6, D7
void setup() {
lcd.begin(16, 2); // Initialize the LCD
lcd.print("Project By Dani!"); // Print your name
delay(1000); // Wait for 1 seconds
lcd.clear(); // Clear the LCD screen
dht.begin(); // Initialize the DHT sensor
pinMode(BUZZER_PIN, OUTPUT);
lcd.print("Temp:"); // Display labels on the LCD
lcd.setCursor(0, 1);
lcd.print("Humidity:");
}
void loop() {
// Read temperature and humidity from DHT sensor
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
// Display the readings on the LCD
lcd.setCursor(6, 0);
lcd.print(temperature, 1);
lcd.print("C");
lcd.setCursor(9, 1);
lcd.print(humidity, 1);
lcd.print("%");
// Check if temperature is above a threshold value (adjust as needed)
if (temperature > 25.0) {
// Activate the buzzer
digitalWrite(BUZZER_PIN, HIGH);
} else {
// Deactivate the buzzer
digitalWrite(BUZZER_PIN, LOW);
}
delay(2000); // Delay between readings (adjust as needed)
}