#define TEMP A0
#define BUZZER 2
const float BETA = 3950;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(TEMP, INPUT);
pinMode(BUZZER, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int analogValue = analogRead(TEMP);
float celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
if (celsius < 20 && celsius > 10){
digitalWrite(BUZZER, HIGH);
tone(BUZZER,262,1000);
delay(100);
digitalWrite(BUZZER, LOW);
noTone(BUZZER);
delay(100);
}
if (celsius < 10){
digitalWrite(BUZZER, HIGH);
tone(BUZZER,262,1000);
delay(10);
}
else{
digitalWrite(BUZZER, LOW);
}
}