ServoOffset 建構子

描述

初始化 ServoOffset 類別。

語法


ServoOffset myoffset
ServoOffset myoffset(filename)

參數

filename:伺服機偏移量微調值檔案名稱。

如果有輸入以上參數,則 ServoOffset 在初始化類別時,會自動載入該檔案內容做為初始的偏移量微調值。請注意,您必須將檔案放在 SD 卡根目錄下;假如您的 86Duino 沒有置入 SD 卡,或者 SD 卡內不包含動作檔案,則檔案載入會失敗。

範例

#include <Servo86.h> 

Servo myservo1;
Servo myservo2;
Servo myservo3;

// 從 SD 卡中載入名稱為 offset.txt 伺服機偏移量微調值檔案
ServoOffset myoffset("offset.txt");

void setup() 
{ 
  myservo1.attach(21);
  myservo2.attach(23);
  myservo3.attach(25);

  // 設定各伺服機中心位置誤差的補償量
  myoffset.setOffsets(myservo1, myservo2, myservo3);

  myservo1.setPosition(1000);
  myservo2.setPosition(1500);
  myservo3.setPosition(2000);
  servoMultiRun(); // 轉動各伺服機(將自動補償伺服機中心位置誤差)
} 

void loop() {} 

See also

offsets[]
setOffsets()


函式庫參考主頁面

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.