#include <Servo.h>
Servo myServo;
const int servoPin = 8;
const int potPin = A0; // Connect potentiometer to analog pin A0
void setup() {
myServo.attach(servoPin);
}
void loop() {
// Read the value from the potentiometer
int potValue = analogRead(potPin);
// Map the potentiometer value (0-1023) to servo angle (0-180)
int servoAngle = map(potValue, 0, 1023, 0, 180);
// Set the servo angle
myServo.write(servoAngle);
// Delay for smoother control
delay(15); // Adjust delay time for responsiveness
}