#include <Servo.h>
Servo myServo; // Create a servo object
int potPin = A0; // Analog pin connected to the slide potentiometer
int servoPin = 9; // Digital pin connected to the servo motor
void setup() {
myServo.attach(servoPin); // Attaches the servo to the specified pin
}
void loop() {
int potValue = analogRead(potPin); // Read the value from the potentiometer
int servoAngle = map(potValue, 0, 1023, 0, 180); // Map the potentiometer value to servo angle range (0 to 180)
myServo.write(servoAngle); // Set the servo position based on the mapped angle
delay(15); // Add a small delay for smoother operation (optional)
}