#include <LiquidCrystal.h>
#include <Servo.h>
const int rs =12,en =11,d4 =5,d5 =4 ,d6=3,d7=2;
const int sensorPin =A0;
LiquidCrystal lcd(rs,en,d4,d5,d6,d7);
const float BETA = 3950;
Servo myservo;
int servoPin1 =9;
int servoPin2 =10;
int reading;
float temp;
int open1 = 90;
int open2 =90;
void setup() {
Serial.begin(9600);
lcd.begin(16, 2);
Serial.println("start");
myservo.attach(servoPin1);
myservo.attach(servoPin2);
}
void loop() {
reading = analogRead(sensorPin);
temp = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
Serial.print("Temperature: ");
Serial.print( temp);
Serial.println(" ℃");
delay(1000);
if (Serial.available()) {
delay(100);
lcd.clear();}
if(temp>30){
servoPos = open1;
myservo.write(servoPos);
delay(5000);
lcd.print("Temp is:");
lcd.print(temp);
lcd.print("c")
delay(1000);
lcd.clear();
}
else if(temp<30){
servoPos = open2;
myservo.write(servoPos);
delay(5000);
lcd.print("Temp is:");
lcd.print(temp);
lcd.print("c")
delay(1000);
lcd.clear();
}
}