ServoFrameInno.positions[]

[Servo86]

描述

The value of each element of the array corresponds to the position of a robot servo in us.

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

語法

myframe.positions[channel]

參數

  • myframe: the object of ServoFrameInno type.
  • channel: Specify the array element, the range is 0 ~ 44. The nth element value represents the position to be assigned to the nth Servo, please 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.)

Since Innovati action editor supports up to 32-axis servo, when loading action frames from its action frame file using the load() function, only positions[0], positions[1], …, positions[31] will contain valid values. positions[0], positions[1], …, positions[31] will contain valid values, all other array elements are 0.

回傳

範例

#include <Servo86.h>
  
Servo myservo0;
Servo myservo1;
Servo myservo2;
 
ServoFrameInno myframe; // declares a ServoFrameInno 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 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() {}

參考


函式庫參考主頁面

86Duino 參考的文本是根據 Creative Commons Attribution-ShareAlike 3.0 License,部分文本是從 the Arduino reference 修改的。 參考中的代碼示例已發佈到公共領域。

發表評論

上部へスクロール