servo#
Initializing the servo Class#
A Servo Output is created by using the following constructor:
The servo constructor creates a servo object in the specified Three Wire Port.
Parameter |
Description |
|---|---|
|
The 3-Wire Port to use for the Servo Output, whether it’s a port on the |
A Brain or 3-Wire Expander must be created first before they can be used to create an object with the servo Class constructor.
// Create the Brain.
brain Brain;
// Construct a Servo Output "Servo" with the servo class.
servo Servo = servo(Brain.ThreeWirePort.A);
This Servo object will be used in all subsequent examples throughout this API documentation when referring to servo class methods.
Class Methods#
setPosition()#
This method is called in the following ways:
The setPosition(value, units) method sets the position of the Servo using a percentage.
Parameters |
Description |
|---|---|
|
An integer value for the Servo. |
|
The only valid unit for the units in this usecase is |
Returns: None.
// Set the servo position to 10 percent.
Servo.setPosition(10, percent);
The setPosition(value, units) method sets the position of the Servo using a Rotation Unit.
Parameters |
Description |
|---|---|
|
A double value for the Servo. |
|
A valid |
Returns: None.
// Set the servo position to 45.5 degrees.
Servo.setPosition(45.5, degrees);