read()
描述
读取伺服机目前角度。
语法
servo.read()
参数
servo:Servo 型别的变数。
回传
伺服机目前的角度(型别为 double 浮点数),如果伺服机尚未出力,回传值为 0.0。(单位:度)
范例
#include <Servo86.h>
Servo myservo;
double position;
void setup()
{
myservo.attach(9);
myservo.write(90.0); // 让伺服机转到 90 度
delay(100); // 延迟 100 毫秒
position = myservo.read(); // 读取目前角度
Serial.println(position);
}
void loop() {}
See also
- write()
- writeMicroseconds()
- readMicroseconds()
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.
