This is my first ever post and project. I am working on adding an if/else statment to my thermostat. Though I know this is probably a simple issue, I am trying to have some parameters to go off when the sensor reports certain values for my board. by using an if statement I am able to turn on an LED when the sensor reports a value of above 80 degrees F, but i am unable to turn it off when the sensor reports a value below 80 degrees F. Could someone help me shut off the LED. I've tried using a else statement but it wont accept it. Any help would be appreciated; thanks!
const int temperaturePin = 0;
void setup()
{
Serial.begin(9600);
pinMode(13,OUTPUT);
}
void loop()
{
float voltage, degreesC, degreesF;
voltage = getVoltage(temperaturePin);
degreesC = (voltage - 0.5) * 100.0;
degreesF = degreesC * (9.0/5.0) + 32.0;
Serial.print("voltage: ");
Serial.print(voltage);
Serial.print(" deg C: ");
Serial.print(degreesC);
Serial.print(" deg F: ");
Serial.println(degreesF);
if(degreesF > 80)
digitalWrite(13,HIGH);
delay(2000);
}
float getVoltage(int pin)
{
return (analogRead(pin) * 0.004882814);