read()

描述

读取伺服机角度。

语法

servo.read()

参数

servoAIServo 型别的变数。

回传

伺服机目前的角度,如果伺服机尚未出力,回传值为 -1。 (单位:度)

范例

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);  // 让伺服机转到 90 度

  delay(100); // 延迟 100 毫秒

  position = read(); // 读取目前角度

  Serial.println(position);

}

 

void loop() {}

See also

attach()

write()


函式库参考主页面

86Duino 参考资料中的文字修改自 Arduino 参考资料,并根据 知识共享署名-许可证方式共享 3.0 授权相同。参考资料中的程式码范例已发布到公共领域。