setOffset()
描述
设定伺服机的中心位置偏移量。
有些型号的 RC 伺服机由于生产上的差异,彼此在中心位置上可能具有些许误差。此函式可用来补偿伺服机的中心位置误差,一旦透过此函式设定了中心位置偏移量,往后函式库在计算伺服机目标角度时,会自动加上该偏移量来计算实际的目标角度。
语法
servo.setOffset(value)
参数
servo
:Servo
型别的变数。
value
:偏移植,范围:-256~ 256,单位:us。
回传
范例
#include <Servo86.h> Servo myservo; void setup() { myservo.attach(9); myservo.setOffset(-10); // 设定 -10 us 的微调角度 myservo.write(1500); // 将伺服机转动到 1500us 角度 (实际上是 1500 - 10 = 1490us) } void loop() {}
See also
- write()
- writeMicroseconds()
- ServoOffset
The text of the 86Duino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.