Created
April 15, 2015 17:54
-
-
Save trianglegrrl/24701b86c5b5db24998f to your computer and use it in GitHub Desktop.
Spark Core code to control RF remote
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
// | |
// 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