my program is bellow but its not working ,please help!
#include <dht.h>
#include <LiquidCrystal_I2C.h>
#define DHTPIN 2 // Define the pin to which the DHT sensor is connected
#define BUZZERPIN 3 // Define the pin to which the buzzer is connected
dht DHT; // Create a DHT object
LiquidCrystal_I2C lcd(0x27, 16, 2); // Define LCD address and dimensions
unsigned long previousMillis = 0;
const long interval = 3600000; // 1 hour in milliseconds
void setup() {
Serial.begin(9600);
pinMode(BUZZERPIN, OUTPUT);
lcd.begin(16, 2);
lcd.print("Temperature:");
}
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
// Reset the buzzer after 1 hour
digitalWrite(BUZZERPIN, LOW);
previousMillis = currentMillis;
}
delay(2000); // Wait for 2 seconds between readings
int chk = DHT.read11(DHTPIN); // Read data from DHT sensor
float temperature = DHT.temperature; // Get temperature in Celsius
lcd.setCursor(0, 1);
lcd.print(temperature);
lcd.print(" *C");
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" *C");
// Set the desired temperature thresholds
float buzzerOnThreshold = 24.0;
float buzzerOffThreshold = 21.0;
if (temperature >= buzzerOnThreshold) {
// If temperature is 24 degrees or higher, sound the buzzer
digitalWrite(BUZZERPIN, HIGH);
} else if (temperature <= buzzerOffThreshold) {
// If temperature is 21 degrees or lower, turn off the buzzer
digitalWrite(BUZZERPIN, LOW);
}
}