Logo Commands

Here are all the logo commands you can see in the panel on the right. If you need to put some things after the command, they are numbers n, angles a, logo colour names c, words "w, or lists [...].

fd n
Move forward by n units. Also forward
If the pen is down (see pd), a line will be drawn as it moves.
E.g.: fd 10 move forwards 10 units.
bk n
Move backwards by n units. Also backward
If the pen is down (see pd), a line will be drawn in the current colour (see setpc).
E.g.: bk 10 move backwards 10 units.
rt a
Turn right by a degrees. Also right
There are 360˚ in a full turn, so rt 90 will make a quarter turn to the right. The turtle will turn, or rotate, in place, it will not move across the screen.
E.g.: rt 30 turn right by 30˚. rt 360/3 turn right one third of a full turn (120˚).
lt a
Turn left by a degrees. Also left
E.g.: lt 30+10 turn left by 40˚.
pu
Pull the pen up. Also penup
The turtle will move without drawing a line.
pd
Put the pen down. Also pendown
The turtle will draw a line the current colour as it moves.
The pen is already down when you start Logo.
setpc c
Set the line to c. Also setpencolor (US spelling)
c can be a whole number between 0 (black) and 15 (grey) or the colour name shown next to the number. These are the standard logo colours.
E.g.: setpc 4 fd 5 or setpc red fd 4
0 black 1 blue 2 green 3 cyan
4 red 5 magenta 6 yellow 7 white
8 brown 9 tan 10 green 11 aqua
12 salmon 13 purple 14 orange 15 grey
setpc “html-colour
Set the line to html-colour.
If you add a quote to the beginning of the colour name, you can use any of the 140 HTML colour names.
E.g.: setpc "MediumOrchid fd 4
setpc “#hex-colour
Set the line to hex-colour.
If you add a quote mark and a hash to the beginning of the colour, you can mix your own colour from red, green and blue components. These are the HTML Hex colours.
E.g.: setpc "#6a5acd fd 4
setps n
Set the pen size (or width) to n pixels. Also setpensize
E.g.: setps 1 setpc 1 fd 2 draws a short thin blue line.
Purple Mash puts a limit of 100 on the size of the pen.
say “w
Print the word w on a new line at the top left of the screen.
E.g.: say "Hello
wait n
Pause drawing and Wait for n seconds (max 10)
E.g.: wait 4
play […]
Play a sequence of notes given by the list […].
E.g.: play [ G G G A G G D ]

Secret Commands

These commands aren’t in the panel. Try them out anyway.

home
Move the turtle back to its home posiition. It will not draw during this move.
Home is usually the centre of the screen, but if you have moved the turtle by dragging it with the mouse, home is where you dragged it to. Don’t try this with your actual home! It is too heavy.
setxy x y
Move the turtle to the coordinates (x, y) on the screen. It will not draw.
The screen coordinates go from (0, 0) at the top left to (1489, 855) at the bottom right. Each square on the grid is 50 pixels.
E.g.: setxy 100 100 rpt 4 [ fd 2 lt 90 ] draws a square at the top left of the screen.
setheading a
Prepares the turtle’s direction to angle a. Zero is directly up the screen and angles increase clockwise. Unlike rt and lt, setheading takes no notice of where the turtle is already pointing. In addition, the turtle does not actually turn until just before the next drawing command is obeyed. This can be confusing when you are debugging!
E.g.: setxy 10 10 setheading 90 goes to (10,10) and turns to point directly to the right.
random n
Generates a random number between 0 and n-1.
E.g.: rpt 200 [ setxy random 1489 random 855 rpt 4 [ fd 1 rt 90 ] ] draws 200 small squares at random positions on the screen.
setps 1 rpt 1000 [ fd .5 rt random 360 ] generates a random walk. Do you think 1000 repeats will see the turtle go off the screen?
make “name value
Makes a variable called name with the given value. You can use the variable later in another expression using :name.
The code below draws up to 150 squares at random positions. The pen size is randomly chosen between 5 and 20. The sides of each squares is a random colour (except white).
rpt 150 [
    make "length random 5
    make "colour random 15
    if (:colour <> 7) [ ; no white squares
      setps 5 + random 21 ; pen size between 5 and 20
      setpc :colour
      setxy random 1489 random 855
      rpt 4 [ fd 1+:length rt 90 ]
  ]
]

Try adding setheading random 90 before the rpt 4 line.

A Secret Variable

repcount
When you are in a repeat, repcount counts up each time around the loop. So if you do rpt 3 [ say repcount], you will see 1, 2, 3 written down the screen.