Motor29#
Inicializando la clase Motor29#
Un controlador de motor 29, que se utiliza para controlar un motor 393, se crea utilizando el siguiente constructor:
Motor29(port, reverse)
Este constructor utiliza dos parámetros:
Parámetro |
Descripción |
|---|---|
|
The 3-Wire Port that the Motor Controller 29 is connected to, whether it’s a port on the |
|
Optional. Set this Motor to be reversed or not. If set to |
A Brain or 3-Wire Expander must be created first before they can be used to create an object with the Motor29 Class constructor.
# Create the Brain.
brain = Brain()
# Construct a Motor Controller 29 "mc29" with the Motor29 class.
mc29 = Motor29(brain.three_wire_port.a)
This mc29 object will be used in all subsequent examples throughout this API documentation when referring to Motor29 class methods.
Métodos de clase#
spin()#
The spin(direction, velocity, units) method spins the Motor in a specified direction. The Motor is assumed to have a maximum velocity of 100 rpm.
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Parámetros |
Descripción |
|---|---|
|
A valid |
|
Optional. The velocity to spin the Motor. The default velocity is set by the |
|
Optional. A valid |
Devoluciones: Ninguna.
# Spin the Motor forward at velocity set with set_velocity.
mc29.spin(FORWARD)
detener()#
The stop() method stops the Motor.
Devoluciones: Ninguna.
establecer_velocidad()#
The set_velocity() method sets the velocity of the Motor. This will be the velocity used for subsequent calls of the spin() method that do not specify a velocity.
Parámetros |
Descripción |
|---|---|
|
El valor de velocidad a establecer. |
|
A valid |
Devoluciones: Ninguna.
set_reversed()#
The set_reversed() method sets the Motor direction to be reversed or not.
Parámetros |
Descripción |
|---|---|
|
|
Devoluciones: Ninguna.
# Reverse the Motor's direction.
mc29.set_reversed(True)