Created
February 18, 2014 00:00
-
-
Save jonmarkgo/9061828 to your computer and use it in GitHub Desktop.
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
#include <Servo.h> | |
Servo myservo; | |
int servoPin = 12; | |
int lock = 0; | |
int unlock = 180; | |
void setup() { | |
// initialize serial: | |
Serial.begin(9600); | |
myservo.attach(servoPin); | |
myservo.write(lock); | |
} | |
void loop() { | |
// Recieve data from Node and write it to a String | |
while (Serial.available()) { | |
char inChar = (char)Serial.read(); | |
if(inChar == 'V'){ // end character for locking | |
if (myservo.read() >= 90) { | |
Serial.println("L"); | |
myservo.write(lock); | |
delay(3000); | |
} | |
else { | |
Serial.println("U"); | |
myservo.write(unlock); | |
delay(3000); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment