ServoOffsetVstone 建構子
描述
初始化 ServoOffsetVstone 類別。
ServoOffsetVstone 是繼承於 ServoOffset 類別,能從 RobovieMaker2 動作編輯器產生的動作設定檔裡載入偏移量微調值。
語法
ServoOffsetVstone myoffset
ServoOffsetVstone myoffset(filename, offset_name)
參數
filename
:由 RobovieMaker2 所產生的 .ini 動作設定檔名稱。
offset_name
:RobovieMaker2 動作設定檔中的偏移量微調值(Offset)名稱(可在 RobovieMaker2 中查詢取得)。
如果有輸入以上兩個參數,則 ServoOffsetVstone 在初始化類別時,會自動從該檔案載入偏移量微調值做為初始值。請注意,您必須將檔案放在 SD 卡根目錄下;假如您的 86Duino 沒有置入 SD 卡,或者 SD 卡內不包含動作檔案,則檔案載入會失敗。
範例
#include <Servo86.h> Servo myservo1; Servo myservo2; Servo myservo3; // 從 SD 卡中的 vstone_offset.ini 設定檔裡載入名為 Offset 0 的偏移量微調值 ServoOffsetVstone myoffset("vstone_offset.ini", "Offset 0"); 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.