Skip to content

Instantly share code, notes, and snippets.

@zsup
Last active December 20, 2015 14:09
Show Gist options
  • Save zsup/6144247 to your computer and use it in GitHub Desktop.
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).
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