Skip to content

Instantly share code, notes, and snippets.

@jonmarkgo
Created February 18, 2014 00:00
Show Gist options
  • Save jonmarkgo/9061828 to your computer and use it in GitHub Desktop.
Save jonmarkgo/9061828 to your computer and use it in GitHub Desktop.
#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