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 |
|---|---|
|
The 3-Wire Port that the Motor Controller 29 is connected to, whether it’s a port on the |
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 |
|---|---|
|
The 3-Wire Port that the Motor Controller 29 is connected to, whether it’s a port on the |
|
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.
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 |
|---|---|
|
A valid |
// 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 |
|---|---|
|
A valid |
|
The velocity to spin the motor. |
|
A valid |
// 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 |
|---|---|
|
The velocity value to set. |
|
The only valid unit for velocity in this usecase is |
Returns: None.
setReversed()#
The setReversed() method sets the motor direction to be reversed or not.
Parameters |
Description |
|---|---|
|
A boolean or binary value to set the direction reversed or not. |
Returns: None.