I have added the line you suggested and now get A2 to display either a 1 or 0 depending on weather there is the defined difference between my two temperature sensors. It works like a charm. Now I am trying to have it turn on relay 1 on digital input 2. I think I am confusing analog inputs with digital inputs. I am only using the serial monitor so I can see what is going on when testing. How do I get D2 to go HIGH (turning on relay 1) when A2 reads 1? (or am I just complicating things?)
// We'll use analog input 0 and 1 to measure the temperature sensor's
// signal pins.
const int temperatureSPin = 0;
const int temperatureTPin = 1;
int relayPin = A2; // select the pin for the relay
void setup()
{
// declare the relayPin as an OUTPUT:
pinMode(relayPin, OUTPUT);
Serial.begin(9600);
}
void loop()
{
float voltageS,voltageT, degreesCS, degreesCT, degreesF;
voltageS = getVoltage(temperatureSPin);
voltageT = getVoltage(temperatureTPin);
//print voltages at this point. if done after the conversion
//you only get a value of 1 for some reason
Serial.print(" vTank: ");
Serial.print(voltageT);
Serial.print("vSolar: ");
Serial.print(voltageS);
degreesCS = (voltageS - 0.5) * 100.0;
degreesCT = (voltageT - 0.5) * 100.0;
degreesF = degreesCS * (9.0/5.0) + 32.0;
{
if ((degreesCS-degreesCT)>1) digitalWrite (relayPin,HIGH);
else digitalWrite (relayPin,LOW);
}
Serial.print(" deg CS: ");
Serial.print(degreesCS);
//Serial.print(" deg F: ");
//Serial.println(degreesF);
Serial.print(" deg CT: ");
Serial.print(degreesCT);
Serial.print(" relayPin: ");
Serial.println(digitalRead(relayPin));
delay(1000); //off time
}
float getVoltage(int pin)
{
return (analogRead(pin) * 0.004882814);
}
/*void loop()/*my second if else statement that gives more errors grrrrr
{
if (relayPin,HIGH)digitalWrite (A2,HIGH);
else digitalWrite (A2,LOW);
}*/