ServoFrame.positions[]

[Servo86]

説明

The value of each element of the array corresponds to the position of a robot servo, and the unit is us.

If the ServoFrame is not specified to load the action frame file during initialization, the user can set the action frame by setting the element value of this array directly.

Syntax

myframe.positions[channel]

Parameters

  • myframe: the object of ServoFrame type.
  • channel: Specifies the array element, ranging from 0 to 44. The nth element value represents the position to be assigned to the nth Servo, see the example below. (Note: On 86Duino One, all array elements are valid; on 86Duino EduCake, only the range of 0 ~ 25 is valid; on 86Duino Zero, only the range of 0 ~ 16 is valid.)

Returns

None.

Example

#include <Servo86.h>
  
Servo myservo0; // 0th Servo
Servo myservo1; // 1st Servo
Servo myservo2; // 2nd Servo
ServoFrame myframe; // declare an action frame object
 
void setup()
{
   myservo0.attach(9);
   myservo1.attach(11);
   myservo2.attach(5);
 
   myframe.positions[0] = 1800; // set the action frame content
   myframe.positions[1] = 1300;
   myframe.positions[2] = 2000;
 
   // Set the time to rotate the servo 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 turning
}
 
void loop() {}

See also


Libraries Reference Home

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

コメントする

上部へスクロール