read()
描述
讀取伺服機角度。
語法
servo.read()
參數
servo
:AIServo
型別的變數。
回傳
伺服機目前的角度,如果伺服機尚未出力,回傳值為 -1。(單位:度)
範例
#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
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.