Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 14

Logo Dance

620 Control
&
Elementary
Programming
Course

C. Rutter 1 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910783.doc
February 03

C. Rutter 2 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910783.doc
620 What shape do you get?

Type in
repeat 5 [ fd 40 rt 72 ]

What shape do you get?

Try changing the numbers in the expression

What other shapes can you draw?

Try this:

repeat 6 [ repeat 10 [ rt 96 fd 100] fd 20 rt 60 ]

If you are not sure what is happening, put in a wait. It will go slower.

repeat 6 [ repeat 10 [ rt 96 fd 100] wait 10 fd 20 rt 60 ]

blue

C. Rutter 3 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910783.doc
Repeating Yourself 621
You can use the repeat command to draw shapes
repeat 3[fd 50 rt 120]

What shape does this draw?


You can also embed a repeat command inside another repeat command
like this

repeat 12 [ repeat 3 [ fd 50 rt 120 ] rt 10 ]

Can you explain what is happening?

Try embedding repeat commands to draw other patterns with spinning


shapes.

blue

C. Rutter 4 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910783.doc
622 Polygons and Talking Turtle

Type in this procedure

to polygon :size :angle


repeat 10 [fd :size lt :angle]
end
Investigate

Now edit the program to read


to polygon :size :angle
while [“true] [fd :size lt :angle]
end
polygon 50 50
You may like to use the halt button.
Why did that happen. Talk turtle with a friend.- You say each command,
and your friend shows you what it does with a pencil on a piece of paper.
Can you find the problem?

Investigate, improve on the polygon program and try your own tests.
What polygons can you make?

orange

C. Rutter 5 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910783.doc
Programming: Debugging. 623
Type this in exactly

to redcircle

set pc 4 setfc 4
repeat 360 [ fd2 rt 1]
pu
rt 90 fd 20
fill
bk 90 lt 20
end

You have defined the procedure redcircle- look in the text window
(commander) and check what the computer says.

Now try running it by typing


redcircle

What happens? Look at what the computer tells you in the text window,

There are four mistakes in this procedure. Use the edall to enter the
editor and cursor keys to go back and change them. (You may only see
two or three at first.)

To actually tell the computer that you've edited the procedure you must
File/Save and Exit. Two errors are easy to find. They are called syntax
errors- errors that break the turtles rules of spelling and grammar. The
other two are logical errors- thats down to you. You are correctly telling
the turtle to something that you don’t want. Don’t believe me-type this.
redcircle
redcircle

C. Rutter 6 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910783.doc
You may need to go back and edit the procedure several times before it
works (the debugging cycle).
orange

624 Programming useful tricks


Here are some useful LOGO tricks. Try them.

to arcright :arc :size


repeat :arc [fd :size rt 1]
end

Now type
arcright 40 2

What happens?
Now write one called arcleft.

C. Rutter 7 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910783.doc
yellow

C. Rutter 8 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910783.doc
625 Programming: Drawing the sun

Here is the sun

I wrote two procedures


arcl arcr
glued them together into
ray ;arcr arcl turn arcr arcl maybe .

I then made a procedure sun.

It called circle. Then 20 times drew an invisible spoke from a fixed point
to the rim. Here I called ray.

Can you do the same? Can you make the rays fatter? Can you make the
rays shorter?
yellow

C. Rutter 9 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910783.doc
Programming :626 Village People
Can you write a program to draw this picture?

Plan it carefully on paper.Talk Turtle with your partner.


to building
house
house
end
You have called a procedure house.
Now house will be made up of these procedures
wall.
roof.
window.
window
etc.
When you know exactly what the procedures are, write them and test
them, and then assemble the final program. (Remember to Save it to
Disk - village.lgo).

Some commands that might help you:


back forward hideturtle right
bk fd ht rt
penup pendown showturtle left
pu pd st lt
penerase setpencolor clearscreen

C. Rutter 10 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910783.doc
pe setpc cs
repeat while
Can you add some trees in the garden? Can you make a village?
Save your work-call it village You can use it later. white

C. Rutter 11 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910783.doc
Programming colours- 627
Colours look fantastic on the screen but not very good when printed on a
black and white laser printer.Try this
to it :size
; do stop.condition
if :size <1 [stop]
; do action- first validate input
if :size >15 [make "size 15]
pd setfc :size setpc floodcolor
circle 30+10 * :size
(fill "true)
make "size :size - 1
; do recursion
it :size
end
This shows you the simple colours. Try setpc [100 100 250] to have
great control over the tint. show pencolor prints out the list.
setpc [0 0 130] setfc pencolor is a useful way to set both pen and flood
colour. Press the Status button to get info on the turtle.

The three fill commands are not reliable, and are a great challenge to
use. fill (fill “true) (fill “false)
The turtle cannot spell ‘colour’- he went to school in SouthPark.

 Investigate how to make the more difficult colours, like pink, crimson
and lime green.
 Make five different types of green balloon and name the colours.
 Investigate the colours found in a Monet painting.
 Investigate what happens to colour when it gets further away.
 Investigate the colour of skin. Use pictures in a magazine. See how
Michelangelo did it, see how Rubens did it.
repeat 255
[setpc (list repcount repcount 0) fd repcount+1 rt 70]
white

C. Rutter 12 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910783.doc
628 Quiet as a mouse
A control computer can drive lights, motors and sounds-- think of a burglar alarm

sound [ 440 100 ] What happens


sound [ 440 200] What happens.
440 is the note (A on the piano ) and 100 is the length – this varies according to computer
They must be in square brackets. You can put more pairs inside the bracbkets.

sound [ 440 200 880 200 440 200 880 100 220 50 ]

You can make a tune this way. Here is the note table to help you

C 261 523 Here are two octaves


D 293 587 I have missed out the sharps and flats.
E 329 658 Try and work out what they will be!
F 349 698
G 392 784
A 440 880
B 493 786
C 523 1046

A better way, because it is easier to read is to write some procedures. One for each note.
to a
sound [440 200]
end

to c
sound [440 200]
end

to b
sound [ 493 200]
end

to tune
acaabca
end

We could do with some pauses between the notes- lets call them pp
to pp
wait 20
end

to tune
a pp c pp a a pp b pp c pp pp a
end

If you study an instrument there are many other experiments you might like to try.
How do you program a tune into your mobile phone.
Here is a tune to try.
VERSE CHORUS
GGGGFEGCDEEEDC GFEGCDEC
AAAABCBCAGAGFE ABCBCAGE
GGGGFEGCDEEEDC GFEGCDEC
CCDDCBC CCCC CCDDCBC CCCC
white

C. Rutter 13 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910783.doc
629 Festival Symbols

C. Rutter 14 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910783.doc

You might also like