Servo#

Inicializando la clase Servo#

Una salida servo se crea utilizando el siguiente constructor:

Servo(port)

Este constructor utiliza un parámetro:

Parámetro

Descripción

port

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 Brain o un 3-Wire Expander antes de poder usarlos para crear un objeto con el constructor de la clase Servo.

# Create the Brain.
brain = Brain()
# Construct a Servo Output "servo" with the Servo class.
servo = Servo(brain.three_wire_port.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#

set_position()#

The set_position(value, units) method sets the position of the Servo.

Parámetros

Descripción

valor

El nuevo valor para el Servo.

unidades

Optional. A valid RotationUnits type. The default is PERCENT.

Devoluciones: Ninguna.

# Set the Servo Output to 10 degrees.
servo.set_position(10, DEGREES)