//This line of code is required when using servo's
#include <Servo.h>
const int RedLED = 8;
const int GreenLED = 2;
Servo myServo;
const int servoPin = 9;
void setup() {
// set these LED pins as outputs
pinMode(RedLED, OUTPUT);
pinMode(GreenLED, OUTPUT);
// Attach the servo to the servo pin (required to get ther servo to work)
myServo.attach(servoPin);
}
void loop() {
//Turn red LED on and turn on Green LED
digitalWrite(RedLED, HIGH);
digitalWrite(GreenLED, LOW);
myServo.write(0);
delay(500);
digitalWrite(RedLED, LOW);
digitalWrite(GreenLED, HIGH);
//rotate the servo clockewise 90 degrees
myServo.write(90);
delay(500);
}