#include <Servo.h>
Servo JimServo;
void setup() {
  // put your setup code here, to run once:
JimServo.attach(6);  // My white wire is connected to Pin 6.
Serial.begin(9600);
}
char gate = 0;
void loop() {
  // put your main code here, to run repeatedly:
if (Serial.available()>0) {   // is a character other than 0 available?
  gate=Serial.read();
}
if (gate=='d'){   // if a user has typed a d
Serial.println("\t  Gate is down");
JimServo.write(0);
delay(2000);
}
if (gate=='u'){  // if a user has typed a u
Serial.println("\t Gate is now OPEN");
JimServo.write(180);
delay(2000);
}
}
 
No comments:
Post a Comment