read()

Description

Reads the servo angle.

Syntax

servo.read()

Parameters

servo: A variable of type AIServo.

Return

The current angle of the servo. If the servo is not generating any force, the return value will be -1. (Unit: degree)

Example

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

#include <AIServo86.h>

 

AIServoPort(ROBOTIS, AX12) bus;

AIServo myservo;

double position;

 

void setup()

{

  bus.begin(Serial1, 1000000);

  myservo.attach(bus, 9);

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

  delay(100); // Delay 100 milliseconds

  position = read(); // Read the current angle

  Serial.println(position);

}

 

void loop() {}

See also

attach()

write()


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