positions[]

Description

An integer array storing the robot's motion frames. Each array element corresponds to the position of a robot servo, in units of µs.

If no motion frame file is loaded during initialization of ServoFrameVstone, the user can set the motion frames by directly setting the elements of this array.

Syntax

myframe.positions[channel]

Parameters

myframe: An object of type ServoFrameVstone.

channel: Specifies the array element, ranging from 0 to 44. The value of the nth element represents the position to be assigned to the nth Servo, as shown in the example below. (Note: All array elements are valid on 86Duino One; only the range of 0 to 25 is valid on 86Duino EduCake; and only the range of 0 to 16 is valid on 86Duino Zero.)

Since RobovieMaker2 supports 30-axis servos, when using the load() function to  load()  a specified motion frame from its motion frame file, only positions[0], positions[1], …, positions[29] will contain valid values, and the rest of the array elements will be 0.

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 <Servo86.h>

  

Servo myservo0;

Servo myservo1;

Servo myservo2;

ServoFrameVstone myframe; //Declare a ServoFrameVstone object

  

void setup()

{

  myservo0.attach(9);

  myservo1.attach(11);

  myservo2.attach(5);

 

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

  myframe.positions[1] = 1300;

  myframe.positions[2] = 2000;

  // Set the servo to rotate 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 rotating

}

  

void loop() {}

See also

- setPostions()
- playPostions()


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.