Skip to content

Instantly share code, notes, and snippets.

@trianglegrrl
Created April 15, 2015 17:54
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 trianglegrrl/24701b86c5b5db24998f to your computer and use it in GitHub Desktop.
Save trianglegrrl/24701b86c5b5db24998f to your computer and use it in GitHub Desktop.
Spark Core code to control RF remote
//
// http://alainahardie.com/spark-me-up
//
// name the pins
int unlockPin = D2;
int lockPin = D3;
int lockState = 0;
// Send the unlock code
int unlock(String lockNumber) {
digitalWrite(unlockPin, HIGH);
delay(500);
digitalWrite(unlockPin, LOW);
lockState = 1;
return(0);
}
int lock(String lockNumber) {
digitalWrite(lockPin, HIGH);
delay(500);
digitalWrite(lockPin, LOW);
lockState = 0;
return(0);
}
// This routine runs only once upon reset
void setup()
{
pinMode(unlockPin, OUTPUT);
pinMode(lockPin, OUTPUT);
// Initialize both the LEDs to be OFF
digitalWrite(unlockPin, LOW);
digitalWrite(lockPin, LOW);
// Associate the Spark functions and variables
Spark.variable("lockState", &lockState, INT);
Spark.function("unlock", unlock);
Spark.function("lock", lock);
}
void loop() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment