Last active
December 20, 2015 14:09
-
-
Save zsup/6144247 to your computer and use it in GitHub Desktop.
A Gist describing the code on a Spark-powered security system (motion detector and buzzer).
This file contains hidden or 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 motion = 0; | |
int buzzer = 1; | |
void setup() { | |
pinMode(motion, INPUT); | |
pinMode(buzzer, OUTPUT); | |
Spark.variable(motion); | |
Spark.function(buzz); | |
} | |
void loop() { | |
if (motion == HIGH) { | |
if (Spark.connected()) { | |
Spark.event("motion"); | |
} | |
buzz(); | |
} | |
} | |
void buzz() { | |
digitalWrite(buzzer, HIGH); | |
delay(1000); | |
digitalWrite(buzzer, LOW); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment