В момента ресурсът е наличен само на английски

How to rotate a motor 90 degrees without calculating speed and time ratios Pro Preview

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.

Необходимо е да се абонирате за FLLCasts.com, за да достъпите това видео

Абонирай се

  • #2601
  • 13 Mar 2026

This command has three required input parameters:

  1. Motor port – you can enter the motor port directly or use the port keyword to select the motor by its letter.

  2. Degrees – the number of degrees the motor should rotate.

  3. 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:

  1. Set the speed to a negative value:

    motor.run_for_degrees(port.A, 90, -360)
  2. 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)