honestly, I just copied the code from the arduino website and thats what they showed. I dont need the Celsius float for what I am doing. I left it in there and just didnt delete it.
This is how i got it to work. My question is why to I have to assign the other pins to LOW when I only say to turn one HIGH? example: temp >75 so I want Green LED on and all other LEDs and relay Off. If i dont assign a LOW value the other Leds stay on.
void setup()
{
pinMode(2, INPUT); //Analog input 1 for TMP36
pinMode(0, OUTPUT);//Red LED
pinMode(1, OUTPUT);//Relay to turn on Heater
pinMode(3, OUTPUT);//Green LED
pinMode(4, OUTPUT);//Yellow LED
}
//int rawvoltage =0; //Take this out??
void loop()
{
int rawvoltage = analogRead(1); //Read P2
float voltage = (rawvoltage*5.0/1023); //convert rawvoltage to voltage
float Farenheit = (((voltage-0.5)*100)*9/5)+32;
if (Farenheit >= 75)
{
digitalWrite(3,HIGH);
digitalWrite(4,LOW);
digitalWrite(0,LOW);
digitalWrite(1,LOW);
delay(1000);
}
else if ((Farenheit) <75 && (Farenheit) > 68)
{
digitalWrite(4,HIGH);
digitalWrite(3,LOW);
digitalWrite(0,LOW);
digitalWrite(1,LOW);
delay(1000);
}
else if (Farenheit <= 68)
{
digitalWrite(0,HIGH);
digitalWrite(1,HIGH);
digitalWrite(4,LOW);
digitalWrite(3,LOW);
delay(1000);
}
}