#include <Servo.h>
// Create a Servo object
Servo myServo;
int angle = 0;
void setup() {
// Initialize the serial communication
Serial.begin(9600);
// Attach the servo to pin 9
myServo.attach(9);
}
void loop() {
Serial.println("Enter the angle:");
while (Serial.available() == 0) {
// Wait for user input
}
// Read the input angle from the Serial monitor
angle = Serial.parseInt();
// Print the entered angle to Serial monitor
Serial.print("Setting angle to: ");
Serial.println(angle);
// Set the servo position
myServo.write(angle);
// Wait for a short duration to see the movement
delay(500);
}