playPositions()

描述

將代表 Frame 的目標位置列表指定給各伺服機並立即控制伺服機移動到 Frame 指定的角度。

語法


aiservoframerobotis.playPositions()
aiservoframerobotis.playPositions(servo1)
aiservoframerobotis.playPositions(servo1, servo2)
aiservoframerobotis.playPositions(servo1, servo2, ... , servo64)

aiservoframerobotis.playPositions(time)
aiservoframerobotis.playPositions(time, servo1)
aiservoframerobotis.playPositions(time, servo1, servo2)
aiservoframerobotis.playPositions(time, servo1, servo2, ... , servo64)

參數

aiservoframerobotisAIServoFrameRobotis 型別的變數。

servo1 ~ servo64AIServo 型別的變數。

time(可選):伺服機轉到目標位置所需的時間,若沒有輸入設定值或設定值為 0,代表伺服機將會以全速轉動。

回傳

範例

#include <AIServo86.h> 
 
AIServoPort(ROBOTIS, AX12) bus;
AIServo myservo0;
AIServo myservo1;
AIServo myservo2;
AIServoFrameRobotis myframe; // 宣告一個 AIServoFrameRobotis 物件
 
void setup() 
{ 
  bus.begin(Serial1, 1000000);
  myservo0.attach(bus, 9);
  myservo1.attach(bus, 11);
  myservo2.attach(bus, 5);
  myframe.positions[0] = 180; // 設定 Frame 內容
  myframe.positions[1] = 130;
  myframe.positions[2] = 200;
  // 以 500ms 的時間將伺服機轉動到 Frame 指定的位置 (myservo0 轉動到 position[0] 
  // 位置,myservo1 轉動到 position[1] 位置,myservo2 轉動到 position[2] 位置)
  myframe.playPositions(500, myservo0 , myservo1, myservo2); 
} 
 
void loop() {}

See also

positions[]
setPostions()
save()
load()


函式庫參考主頁面

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