#include <Servo.h>
Servo myServo; // Create servo object
int potValue; // Variable to store potentiometer value
int servoAngle; // Variable to store the calculated servo angle
void setup() {
myServo.attach(9); // Attach the servo to pin 9
}
void loop() {
potValue = analogRead(A0); // Read the potentiometer value (0-1023)
servoAngle = map(potValue, 0, 1023, 0, 180); // Map the value to a range of 0-180 for the servo
myServo.write(servoAngle); // Move the servo to the calculated angle
}