#include <DHT.h>
const int DHT11_PIN = 2;
const int LDR_PIN = A0;
const int LED_PIN = 9;
const int BUZZER_PIN = 10;
DHT dht(DHT11_PIN, DHT11);
void setup() {
pinMode(LED_PIN, OUTPUT);
pinMode(BUZZER_PIN, OUTPUT);
Serial.begin(9600);
dht.begin();
}
void loop() {
int ldrValue = analogRead(LDR_PIN);
int tempValue = dht.readTemperature();
int humValue = dht.readHumidity();
Serial.print("Temperature: ");
Serial.print(tempValue);
Serial.print(" C | Humidity: ");
Serial.print(humValue);
Serial.print(" % | Light: ");
Serial.println(ldrValue);
if (tempValue >= 30 && humValue >= 60) {
digitalWrite(LED_PIN, HIGH);
tone(BUZZER_PIN, 1500);
delay(500);
noTone(BUZZER_PIN);
} else if (ldrValue <= 500) {
digitalWrite(LED_PIN, HIGH);
tone(BUZZER_PIN, 1000);
delay(500);
noTone(BUZZER_PIN);
} else {
digitalWrite(LED_PIN, LOW);
}
delay(1000);
}