slipstick:
The basis of if statements is that you test to see IF something is equal/bigger/smaller/other condition than something else. If it is you do something. And maybe you want to add an "Or if it isn't do something different" part which is the "else" part of if/else.So it looks something like:
if (sensorValue1 > 200) // or sensorValue1 <= sensorValue2 or all sorts of other comparisons
{
Do something like maybe switch something on
}
else
{
do something else like maybe switch the thing off
}
Which part of that is causing you trouble? Steve
Ok I know what i did wrong. The else/or Was wrong. I manage to turn it on but it would never go off.
I added this and now it works.
if (sensorValue > 400) digitalWrite(Relay, HIGH);
if (sensorValue < 500) digitalWrite(Relay, LOW);
Maybe not the correct way to do it, but at last now it turns on and off