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 授权相同。参考资料中的程式码范例已发布到公共领域。