positions[]
描述
儲存所有伺服機位置的列表。
此列表中存放所有 channel 的 AIServo 位置,其值可由使用者自行指定。position[] 中第一個元素值,代表第一 channel 的 AIServo 位置,第二個元素值代表第二 channel 的 AIServo 位置,依此類推。
您可以呼叫 attach() 來指定 positions[] 對應到的 AIServo ID。
語法
aiservoframerobotis.positions[channel]
參數
aiservoframerobotis
:AIServoFrameRobotis
型別的變數。
channel
:範圍:0 ~ 63,其值代表第 n channel 的 Servo。
假如您是使用 load() 讀取 RoboPlus Motion 幀檔案,那麼 channel 數將會固定是 26 組,第 0 至第 25 組 channel 的 Servo 角度分別存放在 positions[0]、positions[1] … positions[25],第 26 組以後 positions[] 的內容皆為 0。
回傳
無
範例
#include <AIServo86.h> AIServoPort(ROBOTIS, AX12) bus; AIServo myservo0; AIServo myservo1; AIServo myservo2; AIServoFrameRobotis myframe; // 宣告一個 AIServoFrameRobotis 物件 void setup() { bus.begin(Serial1, 1000000); myservo0.attach(bus, 9); myservo1.attach(bus, 11); myservo2.attach(bus, 5); myframe.positions[0] = 180; // 設定 Frame 內容 myframe.positions[1] = 130; myframe.positions[2] = 200; // 設定以 500ms 的時間將伺服機轉動到 Frame 指定的位置 (myservo0 轉動到 position[0] // 位置, myservo1 轉動到 position[1] 位置, myservo2 轉動到 position[2] 位置) myframe.setPositions(500, myservo0 , myservo1, myservo2); aiservoMultiRun(); // 根據設定值轉動所有伺服機 } 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.