motor29#

Inicializando la clase motor29#

Un controlador de motor 29, que se utiliza para controlar un motor 393, se crea utilizando uno de los siguientes constructores.

The motor29(port) constructor creates a motor29 object in the specified Three Wire Port.

Parámetro

Descripción

port

The 3-Wire Port that the Motor Controller 29 is connected to, whether it’s a port on the Brain, or a 3-Wire Expander.

The motor29(port, reverse) constructor creates a motor29 object in the specified Three Wire Port with the reverse flag set to the specified value.

Parámetro

Descripción

port

The 3-Wire Port that the Motor Controller 29 is connected to, whether it’s a port on the Brain, or a 3-Wire Expander.

reverse

Set this Motor to be reversed or not. If set to true, the Motor will spin in the opposite rotation. The default is false.

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.
motor29 mc29 = motor29(Brain.ThreeWirePort.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()#

Este es un método sin espera y permite que el siguiente método se ejecute sin demora.

Este método se llama de las siguientes maneras:

The spin(dir) method spins the motor in a specified direction at the default velocity. The motor is assumed to have a maximum velocity of 100 rpm.

Parámetros

Descripción

dir

A valid directionType.

// spin motor forward.
mc29.spin(forward);

The spin(direction, velocity, units) method spins the motor in a specified direction at the specified velocity. The motor is assumed to have a maximum velocity of 100 rpm.

Parámetros

Descripción

direction

A valid directionType.

velocity

La velocidad para girar el motor.

units

A valid velocityUnit.

// spin motor forward at 100 rpm.
mc29.spin(forward, 100, rpm);

Devoluciones: Ninguna.

stop()#

The stop() method stops the motor.

Devoluciones: Ninguna.

setVelocity()#

The setVelocity(velocity, units) 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.

Este es un método sin espera y permite que el siguiente método se ejecute sin demora.

Parámetros

Descripción

velocity

El valor de velocidad a establecer.

units

The only valid unit for velocity in this usecase is percent.

Devoluciones: Ninguna.

setReversed()#

The setReversed() method sets the motor direction to be reversed or not.

Parámetros

Descripción

value

Un valor booleano o binario para establecer si la dirección se invierte o no.

Devoluciones: Ninguna.