#include <Servo.h> // Include the Servo library
Servo myServo; // Create a servo object
int ledPin = 13; // LED connected to digital pin 13
int servoPin = 9; // Servo connected to digital pin 9
void setup() {
myServo.attach(servoPin); // Attach the servo to pin 9
pinMode(ledPin, OUTPUT); // Set the LED pin as an output
}
void loop() {
// Move the servo to 0 degrees
myServo.write(0);
digitalWrite(ledPin, LOW); // Turn the LED off
delay(1000); // Wait for 1 second
// Move the servo to 90 degrees
myServo.write(90);
digitalWrite(ledPin, HIGH); // Turn the LED on
delay(1000); // Wait for 1 second
// Move the servo to 180 degrees
myServo.write(180);
digitalWrite(ledPin, LOW); // Turn the LED off
delay(1000); // Wait for 1 second
}