Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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