servo#
Inicializando la clase servo#
Una salida servo se crea utilizando el siguiente constructor:
The servo constructor creates a servo object in the specified Three Wire Port.
Parámetro |
Descripción |
|---|---|
|
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.
Métodos de clase#
setPosition()#
Este método se llama de las siguientes maneras:
The setPosition(value, units) method sets the position of the Servo using a percentage.
Parámetros |
Descripción |
|---|---|
|
Un valor entero para el servo. |
|
The only valid unit for the units in this usecase is |
Devoluciones: Ninguna.
// 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.
Parámetros |
Descripción |
|---|---|
|
Un valor doble para el Servo. |
|
A valid |
Devoluciones: Ninguna.
// Set the servo position to 45.5 degrees.
Servo.setPosition(45.5, degrees);