To move a motor, we set the speed at which it moves and how long it should run. There is a command that allows you to set both at the same time.
The command is:
await motor.run_for_time(port.A, 2000, 1000)
This command has three input parameters:
- Motor – the first parameter (port.A in the example) selects which motor will move.
- Duration – the second parameter (2000 in the example) tells the motor how long to run, in milliseconds (2000 ms = 2 seconds).
- Speed – the third parameter (1000 in the example) sets how fast the motor moves, in degrees per second.
The word "await" before the command tells the program to wait until the motor finishes moving. Without it, the program will continue running other commands at the same time, which may cause problems.