#include <Servo.h>





// Define the pins
const int potPin = A0;  // Potentiometer connected to analog pin A0
const int servoPin = 9; // Servo motor control pin

Servo servoMotor; // Create a servo object to control the servo motor

void setup() {
  servoMotor.attach(servoPin); // Attach the servo motor to the servo pin
}

void loop() 
  // put your main code here, to run repeatedly:

{
  int potValue = analogRead(potPin); // Read the potentiometer value (0-1023)

  // Map the potentiometer value to servo motor angle (0-180)
  int angle = map(potValue, 0, 1023, 0, 180);

  // Rotate the servo motor to the mapped angle
  servoMotor.write(angle);

  delay(15); // Delay for smooth movement (adjust as needed)
}