playPositions()

描述

将指定伺服机的目标位置设定为 positions[] 阵列储存的动作帧内容,同时命令伺服机转动。

呼叫 playPositions() 后,您的程式可以去做其他事情,转动伺服机的工作会在背景执行,如果想知道伺服机是否转到目标位置,可以呼叫 isServoMultiMoving() 来检查。

语法


myframe.playPositions()
myframe.playPositions(servo0)
myframe.playPositions(servo0, servo1)
myframe.playPositions(servo0, servo1, ... , servo44)

myframe.playPositions(time)
myframe.playPositions(time, servo0)
myframe.playPositions(time, servo0, servo1)
myframe.playPositions(time, servo0, servo1, ... , servo44)

参数

myframeServoFrameKondo 型别的物件。

servo0 ~ servo44(可选):Servo 型别的物件;其中 servo0 使用 positions[0] 的值,servo1 使用 positions[1] 的值,以此类推。

time(可选):设定伺服机一起转动到目标位置所使用的时间;若没有设定此值,或者将其设定为 0,则伺服机将会以全速转动。

回传

范例

#include <Servo86.h> 
 
Servo myservo0; 
Servo myservo1; 
Servo myservo2;
ServoFrameKondo myframe; // 宣告一个 ServoFrameKondo 物件
 
void setup() 
{ 
  myservo0.attach(9); 
  myservo1.attach(11); 
  myservo2.attach(5);

  myframe.positions[0] = 1800; // 设定 Frame 内容
  myframe.positions[1] = 1300;
  myframe.positions[2] = 2000;

  // 命令所有伺服机以 500ms 时间由当前位置转动到 myframe 指定的位置
  myframe.playPositions(500, myservo0 , myservo1, myservo2); 
} 
 
void loop() {}

See also

positions[]
setPostions()


函式库参考主页面

The text of the 86Duino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.