positions[]
描述
儲存從利基動作檔中讀取到的所有 Servo 角度,單位為 us。
當您呼叫 load() 讀取利基動作檔案後,此陣列便會存放利基動作檔中所有 Servo 的角度值,陣列中第一個元素值,代表第一 channel 的 Servo 角度,第二個元素值代表第二 channel 的 Servo 角度,依此類推。從利基動作檔案中讀取到的 channel 最多為 32 組(例如:Runner A 或 Command 32),最少為 8 組(例如:Runner 8),32 組 channels 分別對應到 86Duino 的第 0 ~ 31 channels,而 8 channels 分別對應到 0 ~ 7 channels。
Servo 的角度您可以自行修改,修改後再呼叫 save() 將新的角度儲存回指定的利基動作檔中。
語法
servoframe.positions[channel]
參數
servoframe
:ServoFrame
型別的變數。
channel
:範圍:0 ~ 45,其值代表第 n channel 的 Servo,請見下面範例說明。
回傳
無
範例
#include <Servo86.h> Servo myservo1; Servo myservo2; Servo myservo3; ServoFrame myframe; void setup() { myservo1.attach(9); // 初始化第一 channel Servo myservo2.attach(11); // 初始化第二 channel Servo myservo3.attach(5); // 初始化第三 channel Servo myframe.positions[0] = 1800; // 設定第一 channel 的 Servo 角度為 1800 us myframe.positions[1] = 1300; // 設定第二 channel 的 Servo 角度為 1300 us myframe.positions[2] = 2000; // 設定第三 channel 的 Servo 角度為 2000 us myframe.setPositions(500); // 設定所有 channel 以 500 ms 的時間轉到目標角度 servoMultiRun(); // 啟動 Servo } void loop() {}
See also
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.