setPostions()

Description

Set the positions[] array values to the corresponding servos.

Grammar

servoframe.setPositions()
servoframe.setPositions(servo1)
servoframe.setPositions(servo1servo2)
servoframe.setPositions(servo1servo2, ... , servo64)

servoframe.setPositions(time)
servoframe.setPositions(time, servo1)
servoframe.setPositions(time, servo1servo2)
servoframe.setPositions(time, servo1servo2, ... , servo64)

Parameters

servoframe: Variable of type AIServoFrame .

servo1 ~ servo64: Variables of type AIServo.

time (optional): The time it takes for the servo to reach the target position. If no value is set or the value is 0, the servo will rotate at full speed.

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

#include <AIServo86.h>

  

AIServoPort(ROBOTIS, AX12) bus;

 

AIServo myservo0;

AIServo myservo1;

AIServo myservo2;

 

AIServoFrame myframe; //Declare a Frame object

  

void setup()

{

  bus.begin(Serial1, 1000000);

  myservo0.attach(bus, 9);

  myservo1.attach(bus, 11);

  myservo2.attach(bus, 5);

  myframe.positions[0] = 180; //Set Frame content

  myframe.positions[1] = 130;

  myframe.positions[2] = 200;

  // Set to Rotate the servo to the position specified by Frame in 500ms (myservo0 rotates to position[0]

  // position, myservo1 rotates to position[1] position, myservo2 rotates to position[2] position)

  myframe.setPositions(500, myservo0 , myservo1, myservo2);

  aiservoMultiRun(); // Rotate all servos according to the set value

}

  

void loop() {}

See also

positions[]


Library Reference Home 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.