ServoOffset.offsets[]

[Servo86]

Description

An integer array that stores the offset trim values for each axis of the robot. The value of each array element ranges from -256 to 256 in us.

If the ServoOffset is not specified to load the offset trim file during initialization, the user can set the offset trim value by setting the element value of this array directly.

Syntax

myoffset.offsets[channel]

Parameters

  • myoffset: The object of ServoOffset type.
  • channel: Specifies an 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
ServoOffset myoffset; // declare a servo offset object
 
void setup()
{
  myservo0.attach(9);
  myservo1.attach(11);
  myservo2.attach(5);
 
  myoffset.offsets[0] = -200; // Set the offset fine-tuning value of each Servo
  myoffset.offsets[1] = 50;
  myoffset.offsets[2] = -100;
 
  // Set the offset fine-tuning value to each servo, that is:
  // The offset trim value of myservo0 is offsets[0],
  // myservo1's offset trim value is offsets[1],
  // Myservo2's offset trim value is offsets[2].
  myoffset.setOffsets(myservo0, myservo1, myservo2);
 
  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
  myframe.setPositions(500, myservo0 , myservo1, myservo2);
 
  // Command all servos to start turning (will automatically correct each servo position with the previously set offset trim value)
  servoMultiRun();
}
 
void loop() {}

See also


Libraries Reference Home

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.

Leave a Comment

Scroll to Top