Teacher's Notes Pro Preview

For today's lesson, the motor should be in the default 0-degree position when building. You can check that it is by the marker placed on the motor.

At the end of this lesson, the students are going to have a small competition. For this purpose, they will need a race track.

Place two objects on the ground (it can be LEGO builds or other handy items) around which the students will program the robots to move around in the shape of a number 8. Mark the starting line at the beginning of a straight line.

content picture

To access the full video please subscribe to FLLCasts.com

Subscribe

  • #2605
  • 24 Mar 2026

"Program the robot to move forward by rotating its tires 2 times."

from hub import port
import motor
import runloop

async def main():
    motor.run_for_degrees(port.A, 720, 1000)

runloop.run(main())

"Program the robot to turn its front tires to the left."

from hub import port
import motor
import runloop

async def main():
    motor.run_for_degrees(port.B, 30, 1000)

runloop.run(main())

"Program the robot to turn its front tires to the left and then move forward by 2 rotations."

from hub import port
import motor
import runloop

async def main():
    await motor.run_for_degrees(port.B, 30, 1000)
    motor.run_for_degrees(port.A, 720, 1000)

runloop.run(main())

"At the end of your program, add a right turn and 2 more forward rotations."

from hub import port
import motor
import runloop

async def main():
    await motor.run_for_degrees(port.B, 30, 1000)
    await motor.run_for_degrees(port.A, 720, 1000)
    await motor.run_for_degrees(port.B, -60, 1000)
    motor.run_for_degrees(port.A, 720, 1000)

runloop.run(main())

"Modify your program to perform the same sequence of actions, but using the run_to_absolute_position command for steering."

from hub import port
import motor
import runloop

async def main():
    await motor.run_to_absolute_position(port.B, 30, 1000)
    await motor.run_for_degrees(port.A, 720, 1000)
    await motor.run_to_absolute_position(port.B, 330, 1000)
    motor.run_for_degrees(port.A, 720, 1000)

runloop.run(main())

"Program the car to park perpendicular with moving only forward."

from hub import port
import motor
import runloop

async def main():
    await motor.run_to_absolute_position(port.B, 30, 1000)
    motor.run_for_degrees(port.A, 1100, 1000)

runloop.run(main())

"Program the car to park perpendicular with moving only backward."

from hub import port
import motor
import runloop

async def main():
    await motor.run_to_absolute_position(port.B, 30, 1000)
    motor.run_for_degrees(port.A, -1100, 1000)

runloop.run(main())

"Place the robot behind the starting line and program it to move forward with the run_for_degrees command, through the two beams marking the track. The robot must stop where you want its first turn to begin."

from hub import port
import motor
import runloop

async def main():
    motor.run_for_degrees(port.A, this number depends on the field, 1000)

runloop.run(main())

"Program the robot to turn around the first beam with the run_to_absolute_position and run_for_degrees commands, and stop in a position where it can move in a straight line between the two beams, but in the opposite direction."

from hub import port
import motor
import runloop

async def main():
    await motor.run_for_degrees(port.A, this number depends on the field, 1000)
    await motor.run_to_absolute_position(port.B, 30, 1000)
    motor.run_for_degrees(port.A, this number depends on the field, 1000)

runloop.run(main())

"Program the robot to move forward with the run_for_degrees command, passing between the two beams marking the track, and to stop where you want its second turn to begin."

from hub import port
import motor
import runloop

async def main():
    await motor.run_for_degrees(port.A, this number depends on the field, 1000)
    await motor.run_to_absolute_position(port.B, 30, 1000)
    await motor.run_for_degrees(port.A, this number depends on the field, 1000)
    await motor.run_to_absolute_position(port.B, 0, 1000)
    motor.run_for_degrees(port.A, this number depends on the field, 1000)

runloop.run(main())

"Program the robot to turn around the second beam marking the track, and to stop behind the start line with the run_to_absolute_position and run_for_degrees commands."

from hub import port
import motor
import runloop

async def main():
    await motor.run_for_degrees(port.A, this number depends on the field, 1000)
    await motor.run_to_absolute_position(port.B, 30, 1000)
    await motor.run_for_degrees(port.A, this number depends on the field, 1000)
    await motor.run_to_absolute_position(port.B, 0, 1000)
    await motor.run_for_degrees(port.A, this number depends on the field, 1000)
    await motor.run_to_absolute_position(port.B, 330, 1000)
    await motor.run_for_degrees(port.A, this number depends on the field, 1000)
    motor.run_to_absolute_position(port.B, 0, 1000)

runloop.run(main())

"Program the robot to do 3 complete laps."

There are several ways to solve this task, and none of them are considered wrong. Repeating the lines of code is also an acceptable solution to this task.