This example program shows how to program the V5 Clawbot to move forward and backward using Modkit.
- A V5 Smart Motor, on Port 1, named LeftMotor.
- A V5 Smart Motor, on Port 10, named RightMotor and set to Reversed.
How it works
when (STARTED) block tells the robot to run this code when the program starts. A number variable,
howMany is declared and assigned to
Then, the left motor is set to start rotating. Since
startRotateFor is used, the motor will begin rotating and the program will continue immediately.
Next, the right motor is set to rotate as well. Since
rotateFor is used, the program will not continue until the motor completes its rotation.
Then, when the right motor has finished rotating, the program will pause for
howMany variable is set to
-2, and the motor rotation blocks are repeated. Since a negative number is given to the motors, they will spin in the opposite direction this time.