At the top of the sketch, I define a few things.
#define no_error 1
#define error_occurred 2
#define error_cleared 3
because English is easier to understand (and remember) than numbers.
The following snippet of code inside
void loop()
fails to compile, with the annoying 'send_EMail' was not declared in this scope error.
if (!digitalRead(BilgePump) && !BilgePumpStatus) {
BilgePumpStatus=1;
send_EMail(error_occurred);
}
else if (digitalRead(BilgePump) && BilgePumpStatus) {
BilgePumpStatus=0;
send_Email(error_cleared);
}
else ...
However, if I comment out the first call to send_Email
if (!digitalRead(BilgePump) && !BilgePumpStatus) {
BilgePumpStatus=1;
// send_EMail(error_occurred);
}
else if (digitalRead(BilgePump) && BilgePumpStatus) {
BilgePumpStatus=0;
send_Email(error_cleared);
}
else ...
things compile fine! So it doesn't like the function call in the IF block, but is fine with it in the ELSE IF block.
One more option. If I change the value sent to the send_Email function,
if (!digitalRead(BilgePump) && !BilgePumpStatus) {
BilgePumpStatus=1;
send_Email(error_cleared);
}
else if (digitalRead(BilgePump) && BilgePumpStatus) {
BilgePumpStatus=0;
send_Email(error_cleared);
}
else ...
it again compiles fine! I'm afraid I just don't get it.
The send_Email function is placed ahead of loop(), because function prototypes (automatic or manual) don't seem to work with the Arduino IDE.
IDE is version 1.8.9. (Tried upgrading to 1.8.10 and everything broke .. maybe 200 errors on the SAME code.)
Any thoughts appreciated.
Alan