→ Motors and Servos Overview
Motor Speed / Power Control
|Motors are controlled by specifying a power level to apply to the motor. Power levels range from -127 to +127. Negative values indicate reverse direction and positive values indicate forward direction. To move motor ‘1’ forward at 50% of full power, you would use the following statement:
motor[port1] = 63; // set port1 to power level 63 (forward, half speed)
|motor is the ROBOTC array variable that controls the motor power and port1 is an enum variable for motor 1.
The default motor operating mode is an “open loop” configuration where the above statement would apply 50% ‘raw’ power to the motor. Open loop control does not result in a consistent speed across all motors; e.g. the speed will become lower as the batteries discharge and different motors will produce different speeds because of minor variations in the motors.