Hi all,
I am trying to rotate two servos with an analog input (0-5 V). I am trying to get a slow and smooth 180deg movement, but my servo motors don't run smoothly. They rotate but with many pauses in between, so it is not smooth at all.
The input voltage I am using is steadily increasing from 0V to 5V within about a minute, so I am not sure where the issue is.
I hope someone can help!
Many thanks in advance ![]()
Here is the code I have been using:
#include <Servo.h>
Servo myservo1;
Servo myservo2;
int const potPin1 = A0;
int potVal1;
int angle1;
void setup() {
myservo1.attach(9);
myservo2.attach(10);
Serial.begin(9600);
}
void loop() {
potVal1 = analogRead(potPin1);
angle1 = map(potVal1, 0, 1023, 0, 179);
myservo1.write(angle1);
myservo2.write(180-angle1);
delay(15);
}