int buzzerPin = 8; // Define the buzzer pin as Pin 8
void setup() {
pinMode(buzzerPin, OUTPUT); // Set the buzzer pin as an output
randomSeed(analogRead(0)); // Seed the random number generator with an analog reading
}
void loop() {
// Simulate temperature and humidity values
float temperature = random(0, 40); // Simulate a temperature value between 0°C and 40°C
float humidity = random(0, 100); // Simulate a humidity value between 0% and 100%
// Generate a buzzer sound based on the temperature
if (temperature > 25.0) {
tone(buzzerPin, 1000); // High-pitched tone for high temperature
} else {
noTone(buzzerPin); // Turn off the buzzer
}
delay(1000); // Delay for a second before the next reading
}