load()

描述

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

語法


servoframe.load(filename)

參數

servofameAIServoFrame 型別的變數。

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

回傳

true:檔案載入成功。
false:檔案載入失敗。

範例

#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()


函式庫參考主頁面

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.