Page 189 - CodePilot V5.0 C8
P. 189
In the above code, the blocks are repeated four times.
Instead of repeating the same block multiple times, the repeat block can be used. It allows for the
efficient execution of a sequence of commands multiple times, making programs more concise
and powerful.
Now, to move the robot on the Grid Map playground in a
zig-zag pattern, use the repeat block. when started
The explanation of the given code is as follows:
repeat 4
The program starts when the when started block is
triggered. turn right for 60 degrees
The robot first turns right by 60 degrees. drive forward for 200 mm
Then, it drives forward for 200 mm. turn left for 60 degrees
It turns left by 60 degrees and drives forward for 200 mm.
drive forward for 200 mm
This process repeats 4 times, with the robot making
small adjustments to create a square-like path.
Program 2 Move the robot to the centre of the Grid Map playground in circular pattern.
The task is to make the robot move in a circular pattern starting from the centre of the Grid Map
playground. The code and output of the given task is as follows:
when started
turn right for 90 degrees
drive forward for 575 mm
turn left for 90 degrees
drive forward for 875 mm
repeat 36
drive forward for 60 mm
turn right for 10 degrees
The explanation of the given code is as follows:
The program starts when the when started block is triggered.
The robot first turns 90 degrees.
Then, it drives forward 575 mm.
It turns left by 90 degrees and drives forward 875 mm.
187
VEXcode VR: Drive, Sense and Create

