#include <Servo.h>
Servo servoMotor; // Create a servo object to control the servo motor
int potPin = A0; // Analog pin to read the potentiometer value
int potValue; // Variable to store the potentiometer value
int servoMin = 0; // Minimum angle of the servo motor
int servoMax = 180;// Maximum angle of the servo motor
void setup() {
servoMotor.attach(11); // Attach the servo to digital pin 9
}
void loop() {
// Read the potentiometer value (0-1023) and map it to servo angle (0-180)
potValue = analogRead(potPin);
int servoAngle = map(potValue, 0, 1023, servoMin, servoMax);
// Control the servo motor position based on the mapped value
servoMotor.write(servoAngle);
delay(15); // Delay to stabilize servo movement (optional)
}