How to control speed of multiple servo motors?

I'm building a robotic arm and I cannot adjust the speed of the servos. They would quickly rotate to the specified angle as if it was just a .write() function. How could I control the speed of the servos?

//include custom library to control servos
#include <Servo.h>

//Create servo variable
Servo base;
Servo arm;
Servo elbow;
Servo wrist;
Servo gripSwivel;
Servo gripper;

int a = 0; //servo position
int b = 0; //servo position
int c = 0; //servo position

void setup()

void loop() 

My current code moves the elbow, wrist and swivels the gripper joint at the same time.

Use VarSpeedServo.h instead of the basic Servo.h. It has a speed parameter to the write().

Or you could write your for loops correctly with the write() commands associated with each loop. See for - Arduino Reference


For 180 degree servos.

The rotation speed of the servo depends on the difference between the starting angle and the target angle, the bigger the difference the faster it turns, and slows down the angle when it is close. So there is no special function to control the rotation speed. But when turning at a large angle, you can use the program to set it into several small angle progressions, which can slow down the speed.

It is also slowed down by delay, but the only way to go fast is to add high voltage .

For 360 degree servos.

The parameters of write() or writeMicroseconds() determine the speed of the servo, but it can also be slowed down by delay() or delayMicroseconds().

I actually used VarSpeedServo.h for my previous robotic arm project. however, I couldn't figure out how to make the joints move at the same time. Do you know what may be the solution to this?

Not a problem I've had with VarSpeedServo but since I can't see what you did I can't tell what you did wrong. Did you perhaps set the 3rd parameter in write() which specifically tells the write to WAIT until the move is complete before moving on?


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