#include <Servo.h>
Servo servo; // Create a servo object
int potPin = A0; // Define the analog pin for the potentiometer
void setup() {
servo.attach(9); // Attach the servo to Pin 9
}
void loop() {
int potValue = analogRead(potPin); // Read the potentiometer value (0-1023)
int servoPosition = map(potValue, 0, 1023, 0, 180); // Map potentiometer value to servo angle (0-180 degrees)
servo.write(servoPosition); // Set the servo motor to the calculated angle
delay(15); // Add a small delay for smoother movement
}