I am sending the temp to float f,
i would like to compare that value to a benchmark temperature to turn on or off a relay.
should i be defining a int value before the void setup
example:
Int benchmarktemp = 68;
Voidsetup()
ect….
How should i convert that 68 so it knows I'm talking about a temperature value and not a char value
if temp is a float then you will need benchmarktemp to be a float to otherwise you are comparing apples and oranges.
float benchmarktemp = 68.0;
Strattonstudios:
I am sending the temp to float f,
i would like to compare that value to a benchmark temperature to turn on or off a relay.
if (f > benchmarktemp)
turnOnRelay ();
Ive posted the code i have as of now. Even setting the the benchmark as a float seems to have no effect on the relay. The relay remains switched constantly.
Thanks guys i appreciate the responses.
Greg
fancontrol.ino (1.06 KB)
This code can never be executed:
if (f >= benchmarktemp);
digitalWrite(RELAY1,LOW);
Move it out of the block that is run if you detect nan. i.e. below the closing brace that currently succeeds it.
The semicolon on this line means that the digitalWrite after it will always be run, regardless of the temperature - get rid of it.
if (f >= benchmarktemp);
But since there's nothing in your code to set that pin HIGH, once it's LOW, it'll stay that way, just as it does now.
You didn't fix this yet:
if (f >= benchmarktemp);
digitalWrite(RELAY1,LOW);
to:
if (f >= benchmarktemp) {
digitalWrite(RELAY1,LOW);
}
What will make it go high? You need code for that.
AHHHH got it guys thanks a bunch!!!!!