Change Servo Speed

I'm wondering if someone knows how to slow the servo down using the servo.h library.

The servo is turning at it's default rate of speed, but I'd like it to turn at about 1/2 (or even 1/4) of the speed.

Here is the code I'm using:

#include "Servo.h"

Servo miservo;
int inBy;

void setup() {
  // attaches a servo connected to pin 10
  miservo.attach(10);  //attach servo to adafruit motor shield
  Serial.begin(9600); //open serial port
  miservo.writeMicroseconds(1450); //set beginning angle
}

void loop() {
  if (Serial.available() >0) {
    inBy = Serial.read();
  if (inBy == 'H') {
    miservo.writeMicroseconds(1900); //turn servo to the LEFT
      }
  if (inBy == 'L') {
    miservo.writeMicroseconds(1000); //turn servo to the RIGHT
    
  }
  if (inBy == 'C') {
    miservo.writeMicroseconds(1450); //turn servo to the CENTER
    
  }
  }
}

Thank you!!! :slight_smile:

To slow a servo down you must send multiple smaller command increments instead of just sending it the final position command you desire, often with time delays before sending each new increment command. Taken to extremes one could even come up with acceleration and deceleration 'curves' to have the servo utilize as well as steady speed.

I see. Thank you. That sounds like something I don't know how to do yet, but will find out. Thanks for the direction.

ScottA1:
I see. Thank you. That sounds like something I don't know how to do yet, but will find out. Thanks for the direction.

Your welcome.
That would be a great early project/sketch design to learn all the proper C/C++ commands (functions) and apply it to something that you can see if it works the way you desired.

Good Luck

You can look at the servo sweep example code to see a way to slow down servo movement. That code probably could be modified like the blink without delay code to remove the delay. The below discussion has a library that accommodates slow servo movements.