Set the target angle of the servo.


servo.setPosition(position, time)


  • servo: The variable of AIServo type.
  • position: The target angle of the floating-point number type, e.g., 90.0, the target position is in “degrees”, i.e., 90 degrees of the servo.
  • time (optional): If there is no input value or the input value is 0, it means the servo will rotate at the fastest speed.




#include <AIServo86.h>
AIServoPort(ROBOTIS, AX12) bus;
AIServo myservo;
void setup()
   bus.begin(Serial1, 1000000);
   myservo. attach(bus, 9);
   myservo.setPosition(150); // Set to rotate to 150 degrees at the fastest speed; // turn the servo
   myservo.setPosition(100, 1000); // set to turn to 100 degrees, it takes 1 second; // turn the servo
void loop() {}

See also

Libraries Reference Home

The text of the 86Duino reference is a modification of the Arduino reference and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top