setOffset()

Description

Sets the servo's offset angle. This function can be used to fine-tune the servo's initialization angle. Once the offset value is set, the library will automatically factor it into the servo's target angle calculation.

Syntax

servo.setOffset(value)

Parameters

servo: A variable of type AIServo.

value: The offset value expressed as a floating-point number, in degrees.

Postback

None

Example

1

2

3

4

5

6

7

8

9

10

11

12

13

14

#include <AIServo86.h>

  

AIServoPort(ROBOTIS, AX12) bus;

AIServo myservo;

  

void setup()

{

  bus.begin(Serial1, 1000000);

  myservo.attach(bus, 9);

  myservo.setOffset(-5); // Sets a -5 degree fine-tuning angle

  myservo.write(150); // Turns the servo to 150 degrees (actually 150 - 5 = 145)

}

  

void loop() {}

See also

attach()


Library Reference Home

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.