readMicroseconds()
描述
讀取伺服機目前角度。
語法
servo.readMicroseconds()
參數
servo:Servo 型別的變數。
回傳
伺服機目前的角度(型別為 unsigned long 整數),如果伺服機尚未出力,回傳值為 0。(單位:us)
範例
#include <Servo86.h>
Servo myservo;
unsigned long position;
void setup()
{
myservo.attach(9);
myservo.write(90.0); // 讓伺服機轉到 90 度
delay(100); // 延遲 100 毫秒
position = myservo.readMicroseconds(); // 讀取目前角度
Serial.println(position);
}
void loop() {}
See also
- write()
- writeMicroseconds()
- read()
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.
