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
:ServoFrameVstone
型別的物件。
servo0 ~ servo44
(可選):Servo
型別的物件;其中 servo0
使用 positions[0]
的值,servo1
使用 positions[1]
的值,以此類推。
time
(可選):設定伺服機一起轉動到目標位置所使用的時間;若沒有設定此值,或者將其設定為 0,則伺服機將會以全速轉動。
回傳
無
範例
#include <Servo86.h> Servo myservo0; Servo myservo1; Servo myservo2; ServoFrameVstone myframe; // 宣告一個 ServoFrameVstone 物件 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[]
- playPositions()
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.