setVelocity()

Description

Sets the servo's speed. Note that this function is only valid if the rotation time has not been set. If you have already set the rotation time by calling setPosition(), the speed set by this function will have no effect.

Syntax

servo.setVelocity(value)

Parameters

servo: A variable of type AIServo.

value: The servo's rotational speed, in degrees per second. If the set speed exceeds the servo's limit, the servo will rotate at its maximum speed. If the input value is 0 or 0.0, the servo will rotate at its maximum speed.

Postback

None

Example

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

#include <AIServo86.h>

  

AIServoPort(ROBOTIS, AX12) bus;

AIServo myservo;

  

void setup()

{

  bus.begin(Serial1, 1000000);

  myservo.attach(bus, 9);

  myservo.write(150); // Turn the servo to 150 degrees

  myservo.setVelocity(100); // Set the velocity to 100 degrees/second

  myservo.write(90); // Start the servo and turn it to 90 degrees at 100 degrees/second

}

  

void loop() {}

See also

attach()


Library Reference Home Page

The text in the 86Duino reference material is modified from the Arduino reference material and is licensed under the Creative Commons Attribution-Share Alike 3.0 License . The code examples in the reference material have been released into the public domain.