Created
January 21, 2015 21:01
-
-
Save kretes/15aed6ba06c9e0a889ea to your computer and use it in GitHub Desktop.
Spark core firmware for simple publishing motion events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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