write()

Description

Sets the servo's target angle and rotates it toward the target angle. Note that calling this function will cause the servo to apply force immediately. Avoid manually rotating the servo to avoid injury or damage.

Syntax

servo.write(position)

Parameters

servo: A variable of type AIServo.

position: The target angle. Enter a floating-point value. For example, 90.0 indicates the target position in degrees, meaning the servo will be at 90 degrees.

Postback

None

Example

1

2

3

4

5

6

7

8

9

10

11

12

13

#include <AIServo86.h>

 

AIServoPort(ROBOTIS, AX12) bus;

AIServo myservo;

 

void setup()

{

  bus.begin(Serial1, 1000000);

  myservo.attach(bus, 9);

  myservo.write(90.0);  // Let the servo rotate to 90 degrees

}

 

void loop() {}

See also

attach()

read()


Library 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.