I pasted the snippet about the test and mistyped the includes by mistake with hopes I would not have to explain why they were defined in the first place. Yet here I am again explaining them for other reasons.
The point is, that when you post code that clearly doesn’t compile, we wonder whether you retyped the whole thing. In other words, are we looking at the code you actually tested? Maybe you reversed a > and a < somewhere? I don’t want to seem pedantic, but copying and pasting the whole sketch is the way to go.
http://snippets-r-us.com/
You seem to have ignored my comments about why it was doing what it was, but just to check I’ve looked at your newer code. Look at this:
if (relayBstate == true)
{
digitalWrite(Relay_B, TURN_ON);
Serial.print("\t");
Serial.println(F("Feeding the plants")); // Text printed to serial monitor
Serial.print("\t");
}
else relayBstate = false; // Turn off time for FeedPump1, OFF 9:10am
{
digitalWrite(Relay_B, TURN_OFF);
}
First, you normally don’t test a boolean for “== true” because this looks cleaner:
if (relayBstate)
Now, you think “what does ‘true’ or ‘false’ mean for a relay”? It is like saying “is my door true or false?”.
Surely a better test would be:
if (relayBClosed) ...
Now we know that “true” means “closed” and “false” means “not closed”.
Moving on …
if (relayBstate == true)
{
...
}
else relayBstate = false; // Turn off time for FeedPump1, OFF 9:10am
If the relayBstate is false, make it false. How does this do anything useful?
Next:
if (relayBstate == true)
{
...
}
else
relayBstate = false; // Turn off time for FeedPump1, OFF 9:10am
// this is always done ! ---------------------------
{
digitalWrite(Relay_B, TURN_OFF);
}
If you indented your code with the auto-indent tool you might have spotted this. Regardless of relayBstate you always turn the relay off. Presumably not what you intend. Those lines do not fall under the scope of the else.