aiservoMultiRun()

[AIServo86]

描述

Start multiple servos at the same time. After calling this function, the behavior of each servo is the same as the behavior of run().

語法

aiservoMultiRun()
aiservoMultiRun(servo1)
aiservoMultiRun(servo1, servo2)
aiservoMultiRun(servo1, servo2, ... , servo64)

參數

servo1 ~ servo64: Variables of AIServo type.

You can enter 1 to 64 servo-type parameters to specify the servo to be activated or enter no parameters; when no parameters are entered in this function, it means to activate all the servos that have been attached().

回傳

範例

#include <AIServo86.h>
  
AIServoPort(ROBOTIS, AX12) bus;
AI Servo servo1;
AIServo servo2;
  
void setup()
{
   bus.begin(Serial1, 1000000);
   servo1.attach(bus, 6); servo2.attach(bus, 10); // use pin 6, 10
   servo1. setPosition(150);
   servo2.setPosition(150);
   aiservoMultiRun(servo1, servo2); // turn servo1, servo2 to the initial position
   delay(500);
}
  
void loop()
{
   servo1.setPosition(250, 2000);
   servo2.setPosition(50, 2000);
   aiservoMultiRun(servo1, servo2); // Make servo1 and servo2 rotate to the new target angle at the same time
   while(isAIServoMultiMoving() == true); // wait for all servos to move to target position
   servo1.setPosition(170, 2000);
   servo2.setPosition(160, 2000);
   aiservoMultiRun(); // Make servo1 and servo2 rotate to the new target angle at the same time
   while(isAIServoMultiMoving() == true); // wait for all servos to move to target position
}

參考


函式庫參考主頁面

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

發表評論

上部へスクロール