#include <Servo.h> // Include the Servo library
// Define the Servo and LED pins
const int ledPin = 8; // LED connected to pin 8
const int servoPin1 = 8; // Servo connected to pin 8
const int servoPin2 = 11; // Servo connected to pin 11
// Create a Servo object
Servo myServo;
void setup() {
// Initialize the servo
myServo.attach(servoPin1);
myServo.attach(servoPin2);
// Set LED pin as output
pinMode(ledPin, OUTPUT);
}
void loop() {
// Move the servo from 0 to 180 degrees
for (int pos = 0; pos <= 180; pos++) {
myServo.write(pos); // Set the servo to the current position
delay(15); // Wait for the servo to reach the position
}
// Move the servo back from 180 to 0 degrees
for (int pos = 180; pos >= 0; pos--) {
myServo.write(pos); // Set the servo to the current position
delay(15); // Wait for the servo to reach the position
}
// Blink the LED (on for 1 second, off for 1 second)
digitalWrite(ledPin, HIGH); // Turn on the LED
delay(1000); // Wait for 1 second
digitalWrite(ledPin, LOW); // Turn off the LED
delay(1000); // Wait for 1 second
}