aiservoMultiRun()

Description

Simultaneously starts multiple servos. After calling this function, the behavior of each servo is the same as calling run().

Grammar

aiservoMultiRun()
aiservoMultiRun(servo1)
aiservoMultiRun(servo1servo2)
aiservoMultiRun(servo1servo2, … , servo64)

Parameters

servo1 ~ servo64: Variable of type AIServo.

You can enter 1 to 64 Servo-type parameters to specify the servos to start, or you can enter no parameters. When this function is called without parameters, it means that all servos that have been attach() are started.

Postback

None

Example

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

#include <AIServo86.h>

  

AIServoPort(ROBOTIS, AX12) bus;

AIServo servo1;

AIServo servo2;

  

void setup()

{

  bus.begin(Serial1, 1000000);

  servo1.attach(bus, 6); ser​vo2.attach(bus, 10); // use pin 6, 10

  servo1.setPosition(150);

  servo2.setPosition(150);

  aiservoMultiRun(servo1, servo2); // Move 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 move to the new target angle simultaneously

  while(isAIServoMultiMoving()  == true); // Wait until all servos have reached their target positions

  servo1.setPosition(170, 2000);

  servo2.setPosition(160, 2000);

  aiservoMultiRun(); // Make servo1 and servo2 rotate simultaneously to the new target angle

  while(isAIServoMultiMoving()  == true); // Wait until all servos have reached their target positions

}

See also

– attach()
– setPosition()
– run()


Library Reference Page

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.