Servo motor issues with analog input

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 :slight_smile:

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);

}

Using Servo.write() will give you a maximum of 180 steps between ends. Using Servo.writeMicroseconds() instead you can get 1000 steps if the servos are capable of it

How are the servos powered? You may get away with powering one unloaded servo with the Arduino 5V, but not 1 loaded servo and definitely not 2.

They are powered using an external power supply. (7.4 V)

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.