#include <Servo.h>
Servo servo;
void setup() {
servo.attach(3);
pinMode(3, OUTPUT);
pinMode(12, INPUT);
pinMode(A0, INPUT);
Serial.begin(9600);
}
void loop() {
const float BETA = 3950; // should match the Beta Coefficient of the thermistor
int analogValue = analogRead(A0);
float celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
int Angle = map(celsius, -24, 80, 0, 90);
Serial.print("Angle: ");
Serial.println(Angle);
delay(500);
servo.write(Angle);
if (digitalRead(12) == HIGH) {digitalWrite(3, HIGH);}
else {digitalWrite(3, LOW);
}
}