I want to find...

検索

Shares

Table of Content

servoMultiRun()

[Servo86]

説明

Command multiple servos to rotate to their target positions at the same time. (This function acts like calling run() for each of the specified servos.)

After calling servoMultiRun(), your program can do other things, and the work of rotating the servos will be executed in the background. If you want to know whether the servos are rotating to the target position, you can call isServoMultiMoving() to check.

構文

servoMultiRun()
servoMultiRun(servo1)
servoMultiRun(servo1, servo2)
servoMultiRun(servo1, servo2, ... , servo45)

媒介変数

  • servo1 ~ servo45: The variables of servo type.

You can input 1 to 45 servo type parameters to specify the servos to be rotated together, or you can not input any parameter, when no parameter is input, it means all the servos already attached() will be rotated at the same time.

戻り値

なし

#include <Servo86.h>
  
Servo servo1;
Servo servo2;
  
void setup()
{
   servo1.attach(6); servo2.attach(10); // use pins 6, 10
   servo1.setPosition(1500);
   servo2.setPosition(1500);
   servoMultiRun(servo1, servo2); // turn servo1 and servo2 to the initial position together
}
  
void loop()
{
   servo1.setPosition(2000, 2000);
   servo2.setPosition(1800, 2000);
   servoMultiRun(servo1, servo2); // make servo1 and servo2 rotate to the new target angle at the same time
   while(isServoMultiMoving() == true); // wait for all servos to go to the target position
   servo1.setPosition(1700, 2000);
   servo2.setPosition(1600, 2000);
   servoMultiRun(); // Make servo1 and servo2 rotate to the new target angle at the same time
   while(isServoMultiMoving() == true); // wait for all servos to go to the target position
}

See also


Libraries Reference Home

86Duino のリファレンスのテキストは Arduino レファレンス を編集したもので、 Creative Commons Attribution-ShareAlike 3.0 License下でライセンスされています。リファレンス内のコードサンプルはパブリックドメインとして公開されています。

上部へスクロール