const float BETA = 3950; // should match the Beta Coefficient of the thermistor
#define led_button 14
#define buzzer 12
void setup() {
Serial.begin(9600);
analogReadResolution(10);
pinMode(15, INPUT);
pinMode(led_button, OUTPUT);
pinMode(buzzer, OUTPUT);
}
void loop() {
int analogValue = analogRead(15);
float celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
Serial.print("Temperature: ");
Serial.print(celsius);
Serial.println(" ℃");
if (celsius >= 35) {
digitalWrite(led_button, HIGH);
tone(buzzer, 150);
}
else {
digitalWrite(led_button, LOW);
noTone(buzzer);
}
delay(500);
}