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:
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)
Курсове и занятия включващи този Урок
Този Урок е използван в следните курсове и занятия.
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 5 - Educational toy: Learn to read the clock
Важно е да даваме обратна връзка на учениците си и се стремим да го правим редовно по време на курса. По-долу ще намерите описание на ранговете, които използваме в училището по роботика, както и на качествата и поведението, които ги определят.
Днес трябва да поставите рангове на учениците си според инструкциите тук.
- 7
- 6
- 14
- 3d_rotation 1