double val;
void setup() {
Serial.begin(9600); // setup serial
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
}
void loop() {
val = analogRead(A0)-123; // read analog input pin 3
float Temp=CtoF(val);
Serial.println(Temp); // print to screen
if (Temp > 85) {
digitalWrite(13,HIGH);
digitalWrite(12,HIGH);
}else{
digitalWrite(13,LOW);
digitalWrite(12,LOW);
}
delay(1000);
}
double FtoC(double F)
{
return ((F-32)*5)/9;
}
double CtoF(double C)
{
return ((C*9)/5) + 32;
}
No comments:
Post a Comment