load()

描述

從指定的檔案中,載入使用者自訂的機器人動作幀(即將檔案中的動作幀儲存至 positions[] 陣列)。

語法

servoframe.load(filename)

參數

servofameAIServoFrame 型別的變數。

filename:檔案的名稱。請注意,目前只支援從 SD 卡根目錄下載入檔案,假如您的 86Duino 上面沒有置入 SD 卡,或者 SD 卡中沒有指定的檔案,載入則會失敗。

回傳

true:檔案載入成功。

false:檔案載入失敗。

範例

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

#include <AIServo86.h>

  

AIServoPort(ROBOTIS, AX12) bus;

AIServo myservo1;

AIServo myservo2;

AIServo myservo3;

AIServoFrame myframe;

  

void setup()

{

  bus.begin(Serial1, 1000000);

  myservo1.attach(bus, 9);

  myservo2.attach(bus, 11);

  myservo3.attach(bus, 5);

  myframe.load("frm0.txt"); // 從指定的檔案載入機器人動作幀

  myframe.playPositions(500, myservo1, myservo2, myservo3); // 以 500 ms 的時間播放此 Frame

}

  

void loop() {}

See also

- positions[]
- setPostions()
- save()


函式庫參考主頁面

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