In this tutorial, you will learn how to rotate a motor to an exact angle using a simple command. This helps you control your robot more precisely without keeping track of its previous movements. It is especially useful when your program becomes longer and more complex.
Необходимо е да се абонирате за FLLCasts.com, за да достъпите това видео
- #2604
- 24 Mar 2026
To solve this tracking problem, we use a command that always moves the motor to a specific angle.
motor.run_to_absolute_position(port, position, velocity)
- port – the motor to control (for example, port.A)
- position – the target angle in degrees
- velocity – the speed in degrees per second
Example:
from hub import port import motor import runloop async def main(): motor.run_to_absolute_position(port.A, 90, 1000) runloop.run(main())
This program turns motor A to 90 degrees at a speed of 1000 deg/s. The motor's direction is chosen automatically. The robot selects the direction that allows the motor to reach its target angle the fastest and rotates it that way.
Choosing the direction
If you need the motor to rotate in a specific direction, you can use the optional direction parameter.
Example:
from hub import port import motor import runloop async def main(): motor.run_to_absolute_position(port.A, 90, 1000, direction = motor.CLOCKWISE) runloop.run(main())
This program turns motor A to 90 degrees at a speed of 1000 deg/s in the clockwise direction.
You can set the direction in four different ways:
- motor.CLOCKWISE
- motor.COUNTERCLOCKWISE
- motor.SHORTEST_PATH
- motor.LONGEST_PATH
Курсове и занятия включващи този Урок
Този Урок е използван в следните курсове и занятия.
Level A: Python Foundations – Robotics with LEGO SPIKE Prime
This is the first level of the LEGO Robotics Curriculum with Python, designed for students in grades 2, 3, and 4.
In this robot adventure, students learn to control robots using real Python code, while teachers guide them through their first steps in text-based programming. Throughout the level, students build a variety of LEGO SPIKE Prime robot models and program them to move, turn, and complete tasks with increasing precision.
Step by step, students learn how to read, understand, and write their own Python programs. Through fun and creative challenges, they bring their robots to life and discover how code can control movement, solve problems, and interact with the world. Along the way, they explore concepts such as navigation, obstacle avoidance, and sensor-based behavior.
The curriculum is designed to help teachers introduce programming in an engaging and approachable way while giving students plenty of opportunities to experiment, test ideas, and develop confidence in their coding skills.
By the end of the level, students apply everything they have learned in an exciting robotics competition. Using their own programs and robot designs, they complete missions on a competition field with boxes, putting their coding, engineering, and problem-solving skills to the test.
- 46
- 4:32
- 78
Lesson 6 - Steering an Unmanned Vehicle
Introduction
Have you heard of self-driving cars? Today, you will try to build one yourself. To create the steering system, you will attach a medium motor that will rotate to steer the robot, and then program the robot to drive.
Before you release your self-driving car onto the streets, it must earn its driver’s license - just like any good driver. At the end of the lesson, you will compete against the other self-driving cars.

- 2
- 7
- 15
- 3d_rotation 1