A Motor Pair connects two motors, allowing us to control them together. Here is how to do that:
Необходимо е да се абонирате за FLLCasts.com, за да достъпите това видео
- #2590
- 24 Feb 2026
Set Up the Motors
To set the pair, we use the command motor_pair.pair(). Here is an example:
from hub import port import runloop import motor_pair async def main(): # Pair motors on ports F and D motor_pair.pair(motor_pair.PAIR_1, port.F, port.D)
The inputs of the motor_pair.pair() command are the following:
- First input = Pair number "motor_pair.PAIR_1"
- Second input= Left motor port "port.F"
- Third input = Right motor port "port.D"
The move_for_time() command
This command allows us to move the tobot for a set amount of time using both motors. Here is an example:
from hub import port import runloop import motor_pair async def main(): # Pair motors on port F and D motor_pair.pair(motor_pair.PAIR_1, port.F, port.D) # Move straight at default velocity for 1 second await motor_pair.move_for_time(motor_pair.PAIR_1, 1000, 0) runloop.run(main())
The inputs of the move_for_time() command are the following:
- First input = Pair number "motor_pair.PAIR_1"
- Second input = The duration in milliseconds
- Third number = The steering (-100 to 100)
The velocity input is an optional input, as such we need to call it by name if we want to change it:
motor_pair.move_for_time(motor_pair.PAIR_1, 1000, 0, velocity=280)