Skip to content

Instantly share code, notes, and snippets.

@dmiddlecamp
Created September 30, 2016 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmiddlecamp/a16abf7a38f3397495dcd461ff45a4ec to your computer and use it in GitHub Desktop.
Save dmiddlecamp/a16abf7a38f3397495dcd461ff45a4ec to your computer and use it in GitHub Desktop.
SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(MANUAL);
#define DISCONNECT_EVERY 5000
unsigned int lastConnect;
bool connectionState = false;
bool state = false;
void setup() {
pinMode(D7, OUTPUT);
}
void loop() {
unsigned int now = millis();
if ((now - lastConnect) > DISCONNECT_EVERY) {
if (connectionState) {
Particle.disconnect();
}
else {
Particle.connect();
}
connectionState = !connectionState;
lastConnect = now;
}
// blink 10 times a second
state = !state;
digitalWrite(D7, (state) ? HIGH : LOW);
delay(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment