 # 360 servo finding a fitting code to adjust the speed

hi there,

I’m working on a project with a servo that can turn 360 degrees (already when i bought it)
But i can’t figure out how to adjust the speed of this servo
This is the code i’m working with

``````Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

void setup() {
myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos);              // tell servo to go to position in variable 'pos'
delay(15);                       // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos);              // tell servo to go to position in variable 'pos'
delay(15);                       // waits 15ms for the servo to reach the position
}
}
``````

Does anyone knows how to adjust the speed to a slower one?

Thank you!

If it is a "continuous rotation" ex-servo, it may move a bit slower around the stop point. Use writeMicroseconds for finer control.

Hi, Increase the delay between servo.write commands from 15 to 30 will slow it down.

360 Servo or continuous servo?

Can you post a link to the specs/data of the servo.

Thanks.. Tom... :)

Does anyone knows how to adjust the speed to a slower one?

The value written to a continuous rotation not-really-a-servo-anymore IS the speed. Values above about 90, up to about 180, cause rotation at increasing speed in one direction. Values below about 90, down to about 0, cause rotation at increasing speed in the other direction.

Instead of using 0 and 180 (maximum speeds in each direction) use numbers closer to 90 (like 80 and 100) for the limits of your control.

Using .writeMicroseconds() where the normal limits are 1000 and 2000 (equivalent to 0° and 180°) pick numbers near 1500 (like 1400 and 1600).

Personally I'd find a potentiometer and change that Sweep example for the more useful Knob example sketch and check for yourself exactly what effect changes in servo.write() values have.

Steve