Docstoc

Logo programming

Document Sample
Logo programming Powered By Docstoc
					Programming with Microworlds Ex and LOGO.

How to use the LOGO booklets: - Each booklet will introduce you to something new. Sometimes it will be something new like a programming technique, or something new like a new programming command, or something new like how to program something. - Each booklet consists of a series of steps that you MUST follow. Often you will be asked to save your program. Please do this properly because I would hate if you were to loose all the hard work you have done. Your saved files are your evidence of the work you have completed - Assessable work is provided in black rows. Each activity has a point value. If you decide to complete a particular activity as part of your assessment work, then you MUST write the activity number and other details on your Student Achievement Worksheet. At the end of the term your worksheet will be reviewed to determine your final mark for this topic. - Make sure your teacher signs off each of completed activities written on your Student Achievement Worksheet as evidence that they have sighted your work. - Have fun ….

1

Lesson 1
When you start up your MicroWorlds EX application, you‟ll see the following screen:

This is the MicroWorlds EX Welcome Screen. On the left is a list of buttons that suggest what you can do next: Free mode Start a brand new MicroWorlds project Open Project Open up a MicroWorlds project you already started Tutorials Get step-by-step instructions in building different projects Samples Look at projects that others have created Quit Close the MicroWorlds application Click on the Free mode button. This will bring up the main MicroWorlds EX window. The picture below is about what you should see when you start a new MicroWorlds project in Free Mode.

Procedure Area Main Window

Command Centre

Tutorials

2

The Command Centre is the place for typing your messages to Logo. The messages that you send to Logo are called programming instructions or statements. Whenever you send Logo an instruction, Logo assumes that the first word in the message is some kind of command. If it knows how to do the command, it tries to do it. If it doesn‟t know how to do the command, it responds by sending a message (an error message) back to you. Error messages are messages that Logo sends you when it‟s confused. These messages can be very useful when you need to figure out why Logo is having a hard time understanding you.

1.1 Learning the basics of Logo
Open Microworlds EX Press on the „Free Mode”. „Free Mode‟ is the programming environment.

1.

Click in the Command Centre and type show “Hello then press the Enter Key LOGO should respond to your command and show you the word Hello You have learnt your first LOGO programming instruction Show
Show shows whatever you have asked it to show.

2.

Click in the Command Centre and type show then press the Enter Key

LOGO should respond to your command and show you the statement Show needs more inputs You have just received your first error message Error messages are messages that Logo sends you when it‟s confused. What does this error message mean? When Logo sees the show command, Logo expects to see something after the word show. If that something isn‟t there, then the show command can‟t be completed, and LOGO tries very hard to complete all commands that it is given. Erase all the commands in the Command Centre by typing cc in the Command Centre
cc Clear all the statements in the Command Centre area

3.

4.

3

1.2 Introduction to Turtle
5. 6. Before you start programming you need to have a turtle on your main window. Next to the Command Centre you have a „Techniques‟ section. In this section you will find most of the answers to your beginner questions.

7.

Click on Turtles (basic). This will open another list of technique tutorials.

8.

Click on Creating, pacing, turning Turtles. Follow the instructions given there. The use of the turtle is extremely important in the LOGO programming language.

9.

There are several ways to return to the main topics in the Help area. One method is to use the button. Press it now. Click on Changing the Turtle’s Shape. Follow the instructions given there. You will change the shape of your turtle to match whatever you are programming for. For example, if you are creating a car racing game your turtle will be in the shape of a car.

10.

11.

Click on The Original Turtle Shape. Read the instructions given there. This instruction is meant to help you. It is good advice. Press the button to return to the instructional topics.

4

1.3 Your First LOGO programs
12. Programming is about typing statements (instructions) that LOGO will be able to follow. In these, your first programs, you will learn how to move your turtle in order to draw a square and a rectangle. If you don‟t have a turtle on our main window then place one there. From now one I will not remind you to do this. JUST REMEMBER YOUR COMMAND CODE WILL NOT WORK UNLESS YOU HAVE HATCHED A TURTLE FIRST. 13. Type the following commands into your Command Centre. Remember to clear your Command Centre before you start. After typing each line of your programming code, press the Return key and then look at your turtle to see what each command actually does to your turtle. home rt 90 rt 90 lt 90 fd 60 fd 30 bk 60
home Puts turtle in screen centre rt 90 Turns turtle right by number of degrees lt 90 Turns turtle left by number of degrees fd 60 Moves turtle forward by given number (input) bk 60 Moves turtle backward by given number (input) These are the 4 main commands for moving your turtle shape. The input value you assign to each command will determine the amount of turn and the amount of movement.

14.

Type the following commands into your Command Centre. After typing each line of your programming code look at your turtle to see what each command actually does to your turtle. cg home pd setc 16 ;set the pen colour setbg 41 ;set the background colour fd 60 rt 90 fd 60 rt 90 fd 60 rt 90 fd 60 rt 90 pu Click on Pen Color and Pen Size tutorial topic. Follow the instructions given there. You will learn how to change the size and colour of your turtle‟s pen.

cg clears the graphics screen pd puts down the turtle‟s pen pu picks up the turtle‟s pen setc 16 sets pen to colour 16 setbg 2 sets the colour of the background setpensize sets the pen size ; allows you to enter a comment

Your program should have drawn a square in red.

15.

5

16. 

On your own: Retype the code statements from step 14 into the command centre, making the square twice as large and changing the colour of the pen for each side of the rectangle. If you want this exercise to be part of your project mark then you will need to show your teacher your work, because this exercise is not saved. On your own:

17.  Work out how you can pick up the pen, then go somewhere else, so that you can draw a second or third shape on the main window. Hint: the turtle only draws when the pen is down. You are required to draw five different shapes on the same main window for this activity. 1. Draw a square. Hint: a square has sides of equal values. 2. Draw a rectangle, any size. 3. Draw a rectangle, any size, using a different colour. Try any input number between 0 and 999. 4. Draw a rectangle, any size, using a different colour for each side. 5. Draw a rectangle, any size, using different colours and different pen sizes for each side. See if you can use the command “setpensize” rather than use the method shown in the tutorial. If you want this exercise to be part of your project mark then you will need to show your teacher your work, because this exercise is not saved. If you can‟t finish this activity in one less then make sure you copy and paste your command centre code into THIS document. That way you can paste in back into the command centre when you return to class. Example:

Copy any Command Centre code here if you didn‟t finish your current activity in one lesson:

6


				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:348
posted:11/29/2009
language:English
pages:6
Jun Wang Jun Wang Dr
About Some of Those documents come from internet for research purpose,if you have the copyrights of one of them,tell me by mail vixychina@gmail.com.Thank you!