setPostions()
描述
将指定伺服机的目标位置设定为 positions[] 阵列储存的动作帧内容。
语法
myframe.setPositions()
myframe.setPositions(servo0)
myframe.setPositions(servo0, servo1)
myframe.setPositions(servo0, servo1, ... , servo44)
myframe.setPositions(time)
myframe.setPositions(time, servo0)
myframe.setPositions(time, servo0, servo1)
myframe.setPositions(time, servo0, servo1, ... , servo44)
参数
myframe
:ServoFrameInno
型别的物件。
servo0 ~ servo44
(可选):Servo
型别的物件。Servo
型别的物件;其中 servo0
使用 positions[0]
的值,servo1
使用 positions[1]
的值,以此类推。
time
(可选):设定伺服机一起转动到目标位置所使用的时间;若没有设定此值,或者将其设定为 0,则伺服机将会以全速转动。
回传
范例
#include <Servo86.h> Servo myservo0; Servo myservo1; Servo myservo2; ServoFrameInno myframe; // 宣告一个 ServoFrameInno 物件 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 指定的位置,即令: // myservo0 转动到 position[0], // myservo1 转动到 position[1] 位置, // myservo2 转动到 position[2] 位置。 myframe.setPositions(500, myservo0 , myservo1, myservo2); servoMultiRun(); // 命令所有伺服机开始转动 } void loop() {}
See also
- positions[]
- playPostions()
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.