Repeat Loops
Clearly, typing those 8 commands in to draw a square is a very inefficient use of time
and can be confusing to students. What we actually want the Pro-Bot to do is draw
one side of the square, then turn 90º, and do that four times.
Of course, Pro-Bot can do that for you. Just tell it to repeat the two commands four
times. Use the key to start this, then a number specifying how many repeats are
required, then your command list, and finally the key to finish the sequence. Pro-Bot
will repeat all commands between these two keys as many times as you specify. For
instance, to draw a 25cm square, press the following keys:
Notice that Pro-Bot changes the order slightly on the display. This is to conform better
to the Logo language specification whilst minimising the number of keys that need to
be pressed. With only five key presses, we have made a much simpler program that can
easily be modified to create other regular shapes.
TIP: If the number after the key is omitted, the loop will be executed 255 times.
Different Step Lengths and Angles
Pro-Bot is not limited to 25cm steps and 90º turns. To go different distances and
angles, simply use the same commands you are used to but add the number of cm or
degrees afterwards. For instance, to move 37cm forward, press:
To turn Pro-Bot left by 30º, press:
Using the number keys and the repeat loops, we can make Pro-Bot trace out more
complex regular polygons, using the same program structure as before, but with
changed numbers and 5cm sides. For instance:
Triangle:
Pentagon:
Hexagon:
Octagon:
Circle (approx):
TIP: To work out how many degrees to turn, divide 360 by the number of sides in the
polygon. So a nine sided nonagon would need to turn by 360/9 = 40º at each step.