390 likes | 1.46k Views
Logo Lesson 1. TBE 540-40 Fall 2004 Farah Fisher. What is Logo?. A programming language (instructions to the computer to perform a task) Created at MIT during a study of artificial intelligence (see http://el.media.mit.edu/logo-foundation/logo/index.html )
E N D
Logo Lesson 1 TBE 540-40 Fall 2004 Farah Fisher
What is Logo? • A programming language (instructions to the computer to perform a task) • Created at MIT during a study of artificial intelligence (see http://el.media.mit.edu/logo-foundation/logo/index.html) • Can be used by virtually any student - from young children through engineering students • Can be used to create pictures, display text, or perform calculations. Some versions can even make music!
What is Logo? • When Logo is used to create pictures, commands are given to a “robot turtle”. • Some samples of the “turtle” shape:
What does Logo look like? • The simplest form of Logo uses movement commands to control the “robot turtle”. • Sample commands: • FD (or FORWARD) moves the turtle forward • BK (or BACK) moves the turtle backwards • RT (or RIGHT) turns the turtle to the right • LT (or LEFT) turns the turtle to the left
What does Logo look like? • Each movement command (FD, BK, RT, LT) needs more information. • FD and BK both require a number, which indicates the “turtle steps” to move (steps are very small). • RT and LT both require the number of degrees in the turn. • Examples (notice the space after the command): • FD 50 (move forward 50 turtle steps) • LT 90 (turn left 90 degrees)
What does Logo look like? • As the turtle moves, it leaves a “trail” on the screen. • These “trails” make shapes. • Imagine for a moment that you are walking around the bases of a baseball diamond, about 30 steps on each side. Assume that you are walking forward from base to base. Are you turning left or right? • Go to the next slide when you finish.
What does Logo look like? • In walking around the baseball diamond in your imagination, you probably followed these steps (written as they would be in Logo): • FD 30 (home to 1st base) • LT 90 (turn toward 2nd base) • FD 30 (1st base to 2nd base) • LT 90 (turn toward 3rd base) • FD 30 (2nd base to 3rd base) • LT 90 (turn toward home) • FD 30 (3rd base to home) • Imagine that you were dragging a paint brush when you walked. What shape would you have drawn?
What does Logo look like? • The commands below would make a square! (turtle shown at the end) FD 30 LT 90 FD 30 LT 90 FD 30 LT 90 FD 30
SHAPE 1 FD 30 RT 90 FD 60 SHAPE 3 FD 50 LT 60 FD 50 SHAPE 2 RT 90 FD 50 LT 90 FD 50 SHAPE 4 FD 100 RT 45 FD 50 What shapes would these make? Try these with pencil and paper. Click to check your answers.
SHAPE 1 FD 30 RT 90 FD 60 SHAPE 3 FD 50 LT 60 FD 50 SHAPE 2 RT 90 FD 50 LT 90 FD 50 SHAPE 4 FD 100 RT 45 FD 50 What shapes would these make?
The REPEAT Command • When you “walked around the bases”, you may have noticed that the Logo commands were repeated. • The REPEAT command is used as a shortcut in place of writing out repeated commands. • Example: REPEAT 2 [FD 50 RT 90] is the equivalent of FD 50 RT 90FD 50 RT 90 • Notice that the number of repeats comes first, with the commands to be repeated inside square brackets.
To make a SQUARE FD 30 LT 90 FD 30 LT 90 FD 30 LT 90 FD 30 OR…to make a SQUARE REPEAT 4 [FD 30 LT 90] This version actually adds another LT 90 to the list, but does not change the basic shape. REPEAT Example
More about REPEAT • You have seen that REPEAT 4 [FD 30 LT 90] makes a square. Guess the shapes made by the REPEAT commands below. Click to see if you were right. REPEAT 3 [FD 30 LT 120] REPEAT 6 [FD 30 LT 60] REPEAT 8 [FD 30 LT 45] REPEAT 5 [FD 30 LT 72]
REPEAT 3 [FD 30 RT 120] REPEAT 8 [FD 30 LT 45] REPEAT 6 [FD 30 LT 60] REPEAT 5 [FD 30 LT 72] More about REPEAT
Did you notice a pattern? • The number after REPEAT is the number of sides. • Examine the number of repeats and the number of degrees. Try multiplying them together. Example: 4 (sides) x 90 (turn) • The sides x degrees should always be the same number in the samples you tried. • Could you use this information to make a 10-sided figure? Click for a possible answer.
Did you notice a pattern? • REPEAT 10 [FD 30 LT 36] should make a 10-sided figure. • Why? Look at the “total turtle turns” below: REPEAT 3 [FD 30 LT 120] 3 x 120 = 360 REPEAT 6 [FD 30 LT 60] 6 x 60 = 360 REPEAT 8 [FD 30 LT 45] 8 x 45 = 360 REPEAT 5 [FD 30 LT 72] 5 x 72 = 360 REPEAT 10 [FD 30 LT 36] 10 x 36 = 360 • When the turtle makes a closed figure (no breaks in the sides), the total turns add up to 360 degrees.
Logo and Critical Thinking • You have just seen an example of the use of Logo to enhance critical thinking. • Your students (and you, too) can be challenged to write the sequential steps needed to make shapes, look for patterns, predict outcomes…all part of critical thinking. • Watch for more examples of critical thinking as you learn Logo.
Changing Things • Here is another prediction task for you. • You have seen that to make a square, you can use REPEAT 4 [FD 30 LT 90] • Do you think the same commands would work if you turned RT instead of LT? • How could you make a square larger? What would you have to change? • After you have made predictions, go to the next slide.
REPEAT 4 [FD 30 LT 90] REPEAT 4 [FD 30 RT 90] REPEAT 4 [FD 10 LT 90] REPEAT 4 [FD 50 LT 90] Were you correct?
Controlling the Logo “Pen” • When the Logo turtle moves, it usually draws with a “pen”. • This pen can be “down” (draws a line) or “up” (does not draw a line). If the pen is up, the turtle moves without drawing. • The pen can also become an eraser (remove a line already drawn). • The pen color abd background can be changed.
Pen Control Commands • PU (PENUP) - subsequent movements of the turtle will not leave a line • PD (PENDOWN) - subsequent movements of the turtle will leave a line • PE (PENERASE) - subsequent movements of the turtle will erase any line it crosses • PPT or PP (PENPAINT) - used by some versions of Logo to “undo” PENERASE
Logo Challenge • How could you use PU and PD to make a dashed line (like the middle of a road)? • Think about this problem for awhile, then click for a possible answer. • Try making the pattern below (turtle always starts pointed “up” with the pen down):
Logo Challenge Two possible solutions for this shape: RT 90 FD 25 PU FD 25 PD FD 25 PU FD 25 PD FD 25 PU FD 25 PD FD 25 Alternate using REPEAT: RT 90 REPEAT 4 [FD 25 PU FD 25 PD] OR…You could draw a line and go back over it with an eraser! (NOTE: Logo commands can be placed on the same line.)
Logo Color • The Logo command to set the pen color is SETPC on most versions of Logo. • The Logo commands to set the background color is SETBG on most versions of Logo. • Each of these commands must be followed by a number (typically from 0 to 15). • The numbers may signify different colors in various version of Logo. You will need to experiment. • NOTE: Some versions of Logo use a menu to choose colors.
Logo Color • Here are some sample commands using color. • SETPC 0 (pen will draw in black) • SETPC 7 (pen will draw in white - probably) • SETBG 3 (screen background will change color) • NOTE: If you set the pen color and the background to the same number, you will not see any drawing!
Self-Check for Lesson 1 • Suppose you enter these commands (with the turtle starting at “home” in the middle of the screen, pointing up): FD 30 RT 90 • Which shape would appear?
Self-Check for Lesson 1 • Suppose you enter these commands (with the turtle starting at “home” in the middle of the screen, pointing up): FD 30 RT 90 • Which shape would appear?
Self-Check for Lesson 1 • Which of the following is a Logo shortcut for FD 50 LT 60 FD 50 LT 60 FD 50 LT 60 • REPEAT 3 (FD 50 LT 60) • REPEAT [LT 60 FD 50] • REPEAT 3 [FD 50 LT 60] • REPEAT [FD 50 LT 60]
Self-Check for Lesson 1 • Which of the following is a Logo shortcut for FD 50 LT 60 FD 50 LT 60 FD 50 LT 60 • REPEAT 3 (FD 50 LT 60) • REPEAT [LT 60 FD 50] • REPEAT 3 [FD 50 LT 60] • REPEAT [FD 50 LT 60]
Self-Check for Lesson 1 • Which of the following sets of Logo commands will move the turtle 50 steps without drawing? • FD 50 PU • PU FD 50 • PE FD 50
Self-Check for Lesson 1 • Which of the following sets of Logo commands will move the turtle 50 steps without drawing? • FD 50 PU • PU FD 50 {PENUP starts no drawing} OR • PE FD 50 {PENERASE also starts no drawing}
Self-Check for Lesson 1 • Suppose you type these three Logo commands: • SETBG 0 SETPC 0 FD 100 • What will you see on the screen?
Self-Check for Lesson 1 • Suppose you type these three Logo commands: • SETBG 0 SETPC 0 FD 100 • What will you see on the screen? You will see the turtle in a different place, but no line. You have instructed the turtle to draw in black on a black background!
Time to Try Logo • Use the class CD-ROM to start Logo or download it from the website at http://www.csudh.edu/fisher/tbe540 • You should see two windows - one for commands and one to show the drawing. FD 50 RT 90 FD 25
Time to Try Logo • Try the activities from Hands-On Exercise 1. This is not a graded exercise. • Experiment with the Logo commands listed on the handout for Week 1.