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 |
---|---|
|
El puerto de 3 cables que se utilizará para la salida del servo, ya sea un puerto en el Cerebro o un Expandedor de 3 cables. |
Primero se debe crear un Cerebro o un Expansor de 3 cables antes de poder usarlos para crear un objeto con el constructor de clase servo.
// 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 |
---|---|
valor |
Un valor entero para el servo. |
unidades |
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 |
---|---|
valor |
Un valor doble para el Servo. |
unidades |
Una rotationUnit válida. |
Devoluciones: Ninguna.
// Set the servo position to 45.5 degrees.
Servo.setPosition(45.5, degrees);