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)

參數

myframeServoFramePololu 型別的物件。

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

time(可選):設定伺服機一起轉動到目標位置所使用的時間;若沒有設定此值,或者將其設定為 0,則伺服機將會以全速轉動。

回傳

範例

#include <Servo86.h> 
 
Servo myservo0; 
Servo myservo1; 
Servo myservo2;

ServoFramePololu myframe; // 宣告一個 ServoFramePololu 物件
 
void setup() 
{ 
  myservo0.attach(9); 
  myservo1.attach(11); 
  myservo2.attach(5);

  myframe.positions[0] = 1800; // 設定動作幀內容
  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.