How to turn the motor 90 degrees without calculating speed and time ratio Pro Preview

We can calculate how much time the motor should turn at a given velocity in order for it to reach the required position, but this will not be necessary. In such cases, it would be much easier to use the run_angle().

To access the full video please subscribe to FLLCasts.com

Subscribe

  • #1559
  • 06 Mar 2020

This command has four input parameters:

  1. The speed at which the motor turns;
  2. How many degrees the motor should turn at;
  3. What type of brake it should use;
  4. Whether or not the program should wait for the command to complete its action.

Here's an example of how the robot can be programmed to move a single motor to 90 degrees with a speed of 360:

Motor(Port.B).run_angle(360, 90)

If we wish to turn the motor in reverse, we can use one of two options:

  1. Set it to a negative speed:
    Motor(Port.B).run_angle(-360, 90)
  2. Set it to a negative angle:
    Motor(Port.B).run_angle(360, -90)

If you set a negative angle and negative speed, the motor will reverse its direction twice and it will move forward:

Motor(Port.B).run_angle(-360, -90)

You can follow this link to read about this command in the pybricks documentation.

Courses and lessons with this Tutorial

This Tutorial is used in the following courses and lessons

Image for Python with LEGO Mindstorms EV3 - Level 1
  • 74
  • 28:18
  • 114