Motor29#

Initializing the Motor29 Class#

A Motor Controller 29, which is used to control a Motor 393, is created by using the following constructor:

Motor29(port, reverse)

This constructor uses two parameters:

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

Optional. 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.
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.

Class Methods#

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.

This is a non-blocking command and allows the next command to run without delay.

Parameters

Description

direction

A valid DirectionType.

velocity

Optional. The velocity to spin the Motor. The default velocity is set by the motor393.motor.set_velocity() command.

units

Optional. A valid VelocityUnits type. The default is RPM.

Returns: None.

# Spin the Motor forward at velocity set with set_velocity.
mc29.spin(FORWARD)

stop()#

The stop() method stops the Motor.

Returns: None.

set_velocity()#

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.

Parameters

Description

value

The velocity value to set.

units

A valid VelocityUnits type. The default is RPM.

Returns: None.

set_reversed()#

The set_reversed() method sets the Motor direction to be reversed or not.

Parameters

Description

value

True to reverse the motor direction. False to maintain the normal direction.

Returns: None.

# Reverse the Motor's direction.
mc29.set_reversed(True)