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.