#include <Servo.h>
Servo myServo;
int potPin = A0; // Potentiometer connected to A0
int potValue = 0; // Variable to store the potentiometer value
int servoPos = 0; // Variable to store the servo position
void setup() {
// put your setup code here, to run once:
myServo.attach(9); // Attach the servo on pin 9 to the servo object
}
void loop() {
potValue = analogRead(potPin); // Read the potentiometer value (0-1023)
servoPos = map(potValue, 0, 1023, 0, 180); // Map potentiometer value to servo angle (0-180)
myServo.write(servoPos); // Set the servo position
delay(105); // Small delay to smooth out the movement
}