motor29#

Initializing the motor29 Class#

A Motor Controller 29, which is used to control a Motor 393, is created by using one of the following constructors.

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

Parameter

Description

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.

Parameter

Description

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.

Class Methods#

spin()#

This is a non-waiting method and allows the next method to run without delay.

This method is called in the following ways:

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.

Parameters

Description

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.

Parameters

Description

direction

A valid DirectionType.

velocity

The velocity to spin the motor.

units

A valid VelocityUnit.

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

Returns: None.

stop()#

The stop() method stops the motor.

Returns: None.

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.

This is a non-waiting method and allows the next method to run without delay.

Parameters

Description

velocity

The velocity value to set.

units

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

Returns: None.

setReversed()#

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

Parameters

Description

value

A boolean or binary value to set the direction reversed or not.

Returns: None.