Skip to content

Instantly share code, notes, and snippets.

@patricksimpson
Created June 1, 2016 15:22
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 patricksimpson/e070f842d50eb4fc51da6e6cb1d4b696 to your computer and use it in GitHub Desktop.
Save patricksimpson/e070f842d50eb4fc51da6e6cb1d4b696 to your computer and use it in GitHub Desktop.
int led = D0;
void setup() {
// This part is mostly the same:
pinMode(led,OUTPUT); // Our LED pin is output (lighting up the LED)
Particle.subscribe("opendoor", myOpen);
Particle.subscribe("closedoor", myClose);
digitalWrite(led, HIGH);
delay(2500);
Particle.publish("Started");
digitalWrite(led, LOW);
}
void loop() {
}
// Now for the myHandler function, which is called when the cloud tells us that our buddy's event is published.
void myOpen(const char *event, const char *data)
{
digitalWrite(led, HIGH);
Particle.publish("Open door!");
}
// Now for the myHandler function, which is called when the cloud tells us that our buddy's event is published.
void myClose(const char *event, const char *data)
{
digitalWrite(led, LOW);
Particle.publish("Close door...");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment