We could calculate how long the motor should rotate at a certain speed in order to reach the required position, but in this case that is unnecessary. Instead, it is much easier to use the motor.run_for_degrees() command.
To access the full video please subscribe to FLLCasts.com
- #2601
- 13 Mar 2026
This command has three required input parameters:
Motor port – you can enter the motor port directly or use the port keyword to select the motor by its letter.
Degrees – the number of degrees the motor should rotate.
-
Speed – the speed at which the command should be executed.
Small motor: -660 to 660
Medium motor: -1110 to 1110
Large motor: -1050 to 1050
Here is an example of how to program the robot to rotate a single motor by 90 degrees at a speed of 360:
from hub import port import motor import runloop async def main(): # Move for 90 degrees at a speed of 360 motor.run_for_degrees(port.A, 90, 360) runloop.run(main())
If we want the motor to rotate in reverse, we can use one of two methods:
-
Set the speed to a negative value:
motor.run_for_degrees(port.A, 90, -360)
-
Set the angle to a negative value:
motor.run_for_degrees(port.A, -90, 360)
If you set both the angle and the speed to negative values, the motor will reverse direction twice, which means it will rotate forward again:
motor.run_for_degrees(port.A, -90, -360)