#include <JC_Button.h> // https://github.com/JChristensen/JC_Button
SYSTEM_THREAD(ENABLED);
IndicatorLED relayPin0(A0);
const byte ASS_BUTTON_PIN(D5);
Button myAssBtn(ASS_BUTTON_PIN);
constexpr char* ASS_MSSG = "ASSISTANCE";
void setup()
{
relayPin0.begin();
myAssBtn.begin();
}
void loop()
{
myAssBtn.read();
if ( myAssBtn.isPressed() )
{
relayPin0.on();
}
if ( myAssBtn.wasPressed())
{
Particle.publish(DEVICE_NAME, ASS_MSSG, 60, PRIVATE);
}
}
Beyond introducing a millis timer, is there any way I can rejig my code so that if there is no network connection, the relayPin0 doesn’t wait for the Particle Publish to go through before noticing it needs to turn off?
I’m guessing that’s what’s causing the relay to remain on when there is no network, anyway!
Thanks