positions[]

描述

儲存使用者自訂的機器人動作幀,即所有 channel 的 Servo 角度。

此陣列中存放所有 channel 的 Servo 角度,其值可由使用者自行指定。position[] 中第一個元素值,代表第一 channel 的 AIServo 角度,第二個元素值代表第二 channel 的 AIServo 角度,依此類推。

最多可指定 64 channels 的 Servo 角度。

語法

servoframe.positions[channel]

參數

servoframeAIServoFrame 型別的變數。 channel:範圍:0 ~ 63,其值代表第 n channel 的 Servo,請見下面範例說明。

回傳

範例

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

#include <AIServo86.h>

  

AIServoPort(ROBOTIS, AX12) bus;

AIServo myservo0;

AIServo myservo1;

AIServo myservo2;

AIServoFrame myframe; // 宣告一個 Frame 物件

  

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

setPostions


 

函式庫參考主頁面

86Duino 參考資料中的文字修改自 Arduino 參考資料,並根據 知識共享署名-許可證方式共享 3.0 授權相同。參考資料中的程式碼範例已發佈到公共領域。