A Motor Pair connects two motors so they can be controlled together. Here is how to do it:
Необходимо е да се абонирате за FLLCasts.com, за да достъпите това видео
- #2590
- 24 Feb 2026
Set up the motors
To create a motor 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:
- 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 the robot to move 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:
- First input = Pair number (motor_pair.PAIR_1)
- Second input = Duration in milliseconds
- Third input = Steering value (from -100 to 100)
The velocity parameter is optional. To change it, you must specify its name:
motor_pair.move_for_time(motor_pair.PAIR_1, 1000, 0, velocity=280)