Skip to content

Instantly share code, notes, and snippets.

@kretes
Created January 21, 2015 21:01
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 kretes/15aed6ba06c9e0a889ea to your computer and use it in GitHub Desktop.
Save kretes/15aed6ba06c9e0a889ea to your computer and use it in GitHub Desktop.
Spark core firmware for simple publishing motion events
int sensorPin = D1;
int LED = D7;
void blink(int times) {
for(int i=0;i<times;i++) {
digitalWrite(LED, HIGH);
delay(100);
digitalWrite(LED, LOW);
delay(100);
}
}
void setup()
{
pinMode(sensorPin, INPUT);
pinMode(LED, OUTPUT);
digitalWrite(LED,LOW);
}
void loop()
{
int motion = digitalRead(sensorPin);
if ( motion == HIGH ) {
blink(1);
Spark.publish("motion");
blink(3);
delay(10000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment