Moving, Turning, and Drawing with the Turtle
FORWARD BACK RIGHT LEFT REPEAT HOME SETHEADING HEADING
This section contains commands you can use to move and turn the turtle.
Once you know how to use these commands, you can create interesting designs with the turtle.
If a command has an abbreviation, it is listed on the second line, below the full name.
FORWARD number
FD number
FORWARD
moves the turtle straight ahead in the direction it is pointing. The distance it moves is the number you give it as input.
For example, this instruction moves the turtle forward 50 steps, or pixels (dots on the screen):
FORWARD 50
» Things to Try
What do you think will happen if you enter each of these instructions? Make a prediction and then try it!
FD -50
FD 3000/50
FD 25 * 25
FD TEN
What is the largest number that FORWARD
will accept?
BACK number
BK number
BACK
moves the turtle in the opposite direction from where it is pointing. The distance it moves is the number you give it as input.
For example, this instruction moves the turtle backward 50 steps, or pixels:
BACK 50
» Things to Try
What do you think will happen if you enter each of these instructions? Make a prediction and then try it!
BK -100
BK 200-100
BK 20000
BK "TWENTY
RIGHT number
RT number
RIGHT
rotates the turtle in a clockwise direction without moving it. The amount it turns (the angle) is the number you give it as input.
For example, this instruction turns the turtle to the right to make a square corner (90°):
RIGHT 90
» Things to Try
What do you think will happen if you enter RT -90
?
What happens if you turn turtle a small amount and then move it FORWARD
a large amount?
Think about these questions:
What number would you use to make an equilateral triangle (where all the sides and angles are the same)?
What number would you use to make a hexagon?
What number would you use to make an octagon?
What number would you use to turn the turtle all the way around?
Can you see a connection between that number and the number of sides in each shape?
LEFT number
LT number
RIGHT
rotates the turtle in a counter-clockwise direction without moving it. The amount it turns (the angle) is the number you give it as input.
For example, this instruction turns the turtle to the left to make a square corner (90°):
LEFT 90
» Things to Try
What do you think will happen if you enter LT -90
?
What about this one? LT 90 + 90
Or this one? LT 45 LT 45
REPEAT number list
If you find yourself typing the same commands over and over using the same pattern, you’ll probably want to learn to use the REPEAT
command.
REPEAT
takes two inputs, a number and a list.
The number tells REPEAT
how many times to run the commands you want.
The list is the set of commands to repeat.
The commands in a list go inside square brackets: [ ]
When you type the first bracket, Logo adds the second one, facing the other way, so you don’t forget to add it yourself.
Here is an example of using REPEAT
:
REPEAT 3 [FD 200 RT 90]
Did this command do what you expected? If not, can you fix it?
» Things to Try
Try fixing these REPEAT
instructions:
Can you make this draw a triangle? REPEAT 3 [FD 180 RT 60]
Can you make this draw a rectangle? REPEAT 2 [FD 50 RT 90 FD 100 RT 36]
Can you make this draw a circle? REPEAT 18 [FD 30 RT 1]
Try some other interesting ways to use REPEAT
!
HOME
HOME
puts the turtle in the center of the screen, where it started.
If the pen is down, it draws a line. See the pen commands page for how to control the pen.
The turtle’s HOME
can also be described using x- and y-coordinates.
Its coordinate position is [0 0].
See the Coordinates page for how to use those commands.
Tip: Beware of including HOME
in procedures that you write. If you do, the turtle will always return to the center of the screen, pointing straight up, which you might not want.
» Things to Try
Move the turtle somewhere on the screen, then type HOME
. Did you get an interesting shape?
Think of other interesting ways to use HOME
.
SETHEADING number
SETH number
SETHEADING
lets you point the turtle in any direction you want. RIGHT
and LEFT
are relative commands, meaning that they start from the where the turtle is already pointing. You can keep typing RT 30
and the turtle will contine to turn a little more each time.
SETHEADING
is different, as its angle is absolute. No matter how many times you type SETH 30
, the turtle will not change the direction it is pointing.
SETHEADING
doesn’t move the turtle at all. It just sets the way it points.
» Things to Try
Look at these commands and see if you can predict what the turtle will do.
SETH 180
SETH 45
SETH -180
SETH 360
HEADING
HEADING
is a reporter. It is a command that gives you information. When you type HEADING
, you will get a result.
The value that HEADING
reports is the angle at which the turtle is pointing.
When you first start up Logo, HEADING
reports 0.
HEADING
doesn’t changing anything about the turtle. It just reports the way it points.
» Things to Try
Try typing HEADING
after you enter a SETHEADING
command.
SETH 90
HEADING
Result: 90
You can use PRINT
with HEADING
, like this:
PR HEADING
0