| For more examples and explanations, head over to Motors and Servos Overview!
|
| Up to 8 motors and/or servos can be connected to the VEX controller. Motor speeds range from -127 (full reverse) through zero (stopped) up to +127 (full forward). There is a small deadband in the motors from about +15 to -15
|
bMotorReflected
| bool bMotorReflected
|
| (bool) Boolean array with one entry for each motor. Indicates that the direction of a motor should be reflected 180 degrees. Useful when mechanical design results in a logical "reversed" condition of a motor.
|
bMotorReflected[port1] = true; // motor 1 WILL be reflected 180 degrees
bMotorReflected[port1] = false; // motor 1 will NOT be reflected 180 degrees
|
|
getEncoderForMotor
| tSensors getEncoderForMotor(tMotor motorIndex)
|
| (tSensors) Returns the sensor port of the encoder paired to motor port, motorIndex.
| Parameter
|
Explanation
|
Data Type
|
| motorIndex
|
A motor port or name
|
tMotor
|
int valueOfEncoder; // set 'valueOfEncoder' to the value...
valueOfEncoder = SensorValue(getEncoderForMotor(port1)); // ...returned by the encoder paired to port1
|
|
mapEncoderToMotor
| void mapEncoderToMotor(tMotor motorPort, tSensors I2CPort)
|
(void) Map an I2C sensor port to the motor it belongs to (when using VEX Integrated Encoder Modules).
This is taken care of in the Motors and Sensors Setup window.
| Parameter
|
Explanation
|
Data Type
|
| motorPort
|
A motor port or name
|
tMotor
|
| I2CPort
|
An I2C sensor port or name
|
tSensors
|
mapEncoderToMotor(port1, I2C_1); // map the encoder in I2C port 'I2C_1' to motor in port 'port1'
|
|
motor
| int motor[tMotor motor]
|
| (int) An array variable with one element for each of the possible motors. This command is used to set the speed (-127 to +127) for a motor. Negative values are reverse; positive forward. Zero is stopped. To drive the motor on port1 at 50% of full power you use the statement motor[port1] = 63;
|
| Parameter
|
Explanation
|
Data Type
|
| motor
|
A motor port or name
|
tMotor
|
|
motor[port1] = 127; // motor 1 is given a power level of 127 (forward)
motor[port1] = -127; // motor 1 is given a power level of -127 (reverse)
|
|
motorType
| word motorType[tMotor motor]
|
| (word) An array variable with one element for each of the possible motors. This command is used to read/write the type of the motor in question.
|
| Parameter
|
Explanation
|
Data Type
|
| motor
|
A motor port or name
|
tMotor
|
|
motorType[port1] = tmotorVex393HighSpeed; // set motor in 'port1' to type 'tmotorVex393HighSpeed'
|
|