setOffset()

描述

設定伺服機的偏移角度。

此函式可用來微調伺服機初始化後的角度,一旦設定了偏移值,往後函式庫在計算伺服機目標角度時,會自動加入該偏移值來計算實際的目標角度。

語法


servo.setOffset(value)

參數

servoAIServo 型別的變數。

value:以浮點數表示之偏移植,單位:度。

回傳

範例

#include <AIServo86.h> 
 
AIServoPort(ROBOTIS, AX12) bus;
AIServo myservo;
 
void setup() 
{ 
  bus.begin(Serial1, 1000000);
  myservo.attach(bus, 9);
  myservo.setOffset(-5); // 設定 -5 度的微調角度
  myservo.write(150); // 將伺服機轉動到 150 度 (實際上是 150 - 5 = 145)
} 
 
void loop() {}

See also

attach()


函式庫參考主頁面

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.