#include <Servo.h>
Servo servoMotor;
int potPin = A0;
int potValue;
int speed;
void setup() {
servoMotor.attach(9); // attach the servo to pin 9
servoMotor.writeMicroseconds(1500); // set the initial position to stop the continuous rotation
}
void loop() {
potValue = analogRead(potPin); // read the value from the potentiometer
speed = map(potValue, 0, 1023, 1000, 2000); // map the potentiometer value to speed range (1000 to 2000, adjust as needed)
servoMotor.writeMicroseconds(1500); // set the servo position to stop the continuous rotation
delay(100); // small delay for stability
servoMotor.writeMicroseconds(1700); // set the servo position for continuous rotation
delay(speed); // delay based on the mapped speed
}