ServoFrame.setPositions()

[Servo86]

描述

Set the target position of the specified servo to the action frame content stored in the positions[] array.

語法

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: the object of ServoFrame type.
  • servo0 ~ servo44 (optional): Servo type objects; servo0 uses the value of positions[0], servo1 uses the value of positions[1], and so on.

(Note: If the above parameter is not entered, the first Servo object that is constructed in the program will be servo0, the second Servo object will be servo1, and so on.)

If this value is not set, or if it is set to 0, the servo will rotate at full speed.

回傳

範例

#include <Servo86.h>
  
Servo myservo0;
Servo myservo1;
Servo myservo2;
 
ServoFrame myframe; // declare an action frame object
  
void setup()
{
   myservo0.attach(9);
   myservo1.attach(11);
   myservo2.attach(5);
 
   myframe.positions[0] = 1800; // set the action frame content
   myframe.positions[1] = 1300;
   myframe.positions[2] = 2000;
 
 
   // Set the time to rotate the servo from the current position to the position specified by myframe in 500ms, that is:
   // myservo0 rotates to position[0],
   // myservo1 rotates to position[1],
   // myservo2 rotates to position[2].
   myframe.setPositions(500, myservo0 , myservo1, myservo2);
 
   servoMultiRun(); // command all servos to start turning
}
  
void loop() {}

參考


函式庫參考主頁面

86Duino 參考的文本是根據 Creative Commons Attribution-ShareAlike 3.0 License,部分文本是從 the Arduino reference 修改的。 參考中的代碼示例已發佈到公共領域。

發表評論

上部へスクロール