#include <Servo.h>

Servo servo;
int servoPin = 10; // Use Pin 10 for Servo 1 (or Pin 9 for Servo 2)

void setup() {
  Serial.begin(9600);
  
  // Attach the servo to the pin
  servo.attach(servoPin);
  
  Serial.println("Enter Angle (0-180):");
  
  servo.write(90);
}

void loop() {
  // Check if user has typed something
  if (Serial.available() > 0) {
    // Read the angle from the Serial Monitor
    int angle = Serial.parseInt();

    // Ensure the angle is within the valid 0-180 range
    angle = constrain(angle, 0, 180);

    // Move the servo
    servo.write(angle);

    Serial.print("Servo moved to: ");
    Serial.print(angle);
    
    while(Serial.available() > 0) Serial.read();
  }
}
