const int potentiometerPin = A5; // Analog pin for the potentiometer
int buzzer = 10;
void setup()
{
pinMode(buzzer, OUTPUT);
Serial.begin(9600);
}
void loop()
{
int potValue = analogRead(potentiometerPin); // Read the potentiometer value
float temp_val = map(potValue, 0, 1023, 0, 100); // Map potentiometer value to temperature range (0-100)
Serial.print("Temperature = ");
Serial.print(temp_val);
if (temp_val > 40) {
Serial.print(" Heat Wave Alert \n");
} else {
Serial.println(" Low Temperature");
}
delay(1000);
if (temp_val > 40) {
digitalWrite(buzzer, HIGH);
} else {
digitalWrite(buzzer, LOW);
}
}