#include <Servo.h>
// Define the servo pin
const int servoPin = 13;
// Define the potentiometer pin
const int potPin = A1;
// Create a Servo object
Servo myServo;
void setup() {
// Attach the servo to the pin
myServo.attach(servoPin);
}
void loop() {
// Read the value of the potentiometer
int potValue = analogRead(potPin);
// Map the potentiometer value to servo position (0 to 180 degrees)
int servoPos = map(potValue, 0, 1023, 0, 180);
// Move the servo to the mapped position
myServo.write(servoPos);
// Optional delay to stabilize readings
delay(50);
}