We can calculate how much time the motor should turn at a given velocity for it to reach the required position, but this will not be necessary. In such cases, it would be much easier to use the motor.run_for_degrees()
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 write the number of the motor, or use the "port" keyword to assign it by its letter;
How many degrees the motor should turn at;
-
The speed with witch to execute the command;
Small motor: -660 to 660
Medium motor: -1110 to 1110
Large motor: -1050 to 1050
Here's an example of how the robot can be programmed to move a single motor to 90 degrees with a speed of 360:
from hub import port import motor import runloop async def main(): #Move for 90 degrees at 360 speed motor.run_for_degrees(port.A, 90, 360) runloop.run(main())
If we wish to turn the motor in reverse, we can use one of two options:
- Set it to a negative speed:
motor.run_for_degrees(port.A, 90, -360)
- Set it to a negative angle:
motor.run_for_degrees(port.A, -90, 360)
If you set a negative angle and negative speed, the motor will reverse its direction twice and it will move forward:
motor.run_for_degrees(port.A, -90, -360)