Good day all:
We need to publish when our building line power drops out, and publish again when it comes back. The plan is to power a relay that takes a digital pin High with power failure, Low with good power. Simple project, but no luck with the following code. Any suggestions would be terrific!
When I rework the indentation (and remove superfluous or “confusing” blanks) of your code it would look like this (to stress the pairing of curly braces I place each of them on a seperate line)
int buttonPin = D5;
void setup()
{
pinmode(buttonpinD5, Input);
// <-- missing closing brace!!
void loop()
{
Startup:
delay(10000); //10 sec
If(digitalRead(buttonPinD5) == High) // <-- C/C++ is case sensitive so it needs to be if and HIGH
{
goto OffWait;
}
else
{
goto Startup // <-- missing semicolon ;
}
OffWait:
delay(120000); // 2 min
If(digitalRead(buttonPinD5) == High) // <-- case sensitive if and HIGH
{
goto PowerOff;
}
else
{
goto Startup // <-- missing semicolon ;
}
PowerOff:
delay (10000); // 10 sec
Particle.publish("Building Power", "Power Is Shutdown", 60, PRIVATE) ;
goto Timer;
} // <-- wrong closing brace
// due to premature closing brace the rest of the rest of the code is not allowed here
Timer:
delay(600000); //10 min
If(digitalRead (buttonPinD5) == Low) // <-- if and LOW
{
goto PowerON;
}
else
{
goto Timer // <-- missing semicolon ;
}
PowerOn // <-- missing colon : for this label
delay(10000); // 10 sec
Particle.publish("Building Power", "Power Is Running", 60, PRIVATE);
goto Startup;
}
But as said, since this is not Basic you need to rid yourself from the Basic (or machinge code ) programming paradigm (e.g. goto) and adopt a more C (procedural) and C++ (object oriented) way of thinking.
Hi:
I want to thank you for your kind help today. I cleaned things up per your instructions and with a few mods, it seems to work! I’m pretty disabled with this stuff and have a lot to learn as I’m certain you know!