#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)
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
pot1:VCC
pot1:SIG
pot1:GND
servo1:GND
servo1:V+
servo1:PWM