#include <Servo.h>
Servo servoMotor;
int potPin = A0; // Analog pin the potentiometer is connected to
int servoPin = 9; // Digital pin the servo motor is connected to
int angle;
void setup() {
servoMotor.attach(servoPin);
}
void loop() {
int potValue = analogRead(potPin); // Read potentiometer value (0-1023)
angle = map(potValue, 0, 1023, 0, 180); // Map potentiometer value to servo angle (0-180 degrees)
servoMotor.write(angle); // Move servo to the mapped angle
delay(15); // Adjust as needed for smoother motion
}