Presentation is loading. Please wait.

Presentation is loading. Please wait.

Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization."

Similar presentations


Presentation on theme: "Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization.""— Presentation transcript:

1 Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization." - Harold Abelson Apple Logo, 1982 Alex Veremeychik Mike Adams

2 History Terrapin Software company was founded in 1977 to market the turtle robot. Introduced it’s first computer version on the Apple II. Logo was originally created by Seymore Papert at MIT in 1967. Designed on top of Lisp as a tool for learning.

3 Who is Terrapin Logo for? Terrapin Logo was primarily designed for K-12 students. Adaptable for all ages. Anyone who’s interested in programming graphical patters or recursive visual algorithms.

4 Terrapin Logo Introduction It’s most noticeable feature is the turtle, a triangular cursor used for drawing patterns. It’s intuitive and has easily understandable commands. Such as RIGHT, LEFT, FORWARD, and BACKWARDS.

5 Introduction Continued The top half, “Graphics”, is used for execution of programs or commands. The bottom half, “Listener”, is used to input commands or create functions.

6 Language Features ProceduralResponsive Can be both interactive and not Multi-threaded Can draw graphics and play sounds Limited RCX commands and features Can implement new Logo-level RCX commands with knowledge of RCX OP- codes

7 More features Not case sensitive Strings are denoted by double quotes in front of the string. Print “Hello Print “HelloHELLO There are 5 basic types of data: Words, Numbers, Lists, Property Lists, and Arrays Words, Numbers, Lists, Property Lists, and Arrays There are 3 types of objects: Turtles, Bitmaps, and Controls Turtles, Bitmaps, and Controls

8 Words Any group of characters including letters, numbers, and punctuation marks that does not contain a space and is not a primitive or procedure. WORD? “Hello WORD? “Hello Result: TRUE WORD? “123GO WORD? “123GO Result: TRUE Numbers in Logo are a special class of words, that have special primitives to deal with them. Names of all procedures in Logo, including primitive procedures, are words, although numbers cannot be used as the name of procedures.

9 Numbers A number can be an integer, a decimal, or a number in exponential notation. 3, 26, 4.7, 12E-7 3, 26, 4.7, 12E-7 Valid numbers range from 1E-308 to 1E308. All calculations in Logo have a precision of 15 digits. Logo expresses number in the range between.000001 to 1000000 in decimal notation and anything smaller or larger in scientific notation. Can interpret both prefix and infix notation. + 2 2 is the same as 2 + 2 + 2 2 is the same as 2 + 2 Does correct order of operations.

10 Lists A list is information in Logo enclosed in square brackets. LIST? [ 1 2 3 ] LIST? [ 1 2 3 ] Result: TRUE Empty list is a list with no elements. Ex. [ ] Lists within lists are allowed. LIST? [ [RED BLUE] [ORANGE GREEN] [BLACK YELLOW] ] LIST? [ [RED BLUE] [ORANGE GREEN] [BLACK YELLOW] ] Result: TRUE Some additional commands: EQUAL?, NAME, THING, WORD, ITEM, LAST, FIRST, EMPTY?, NUMBER?, CHAR EQUAL?, NAME, THING, WORD, ITEM, LAST, FIRST, EMPTY?, NUMBER?, CHAR

11 Property Lists Special type of list that allows assignment of multiple values to a single object in Logo. Syntax: name [property1 value1 propery2 value2 …] name [property1 value1 propery2 value2 …]Example: DOG [BREED DOBERMAN HEIGHT [14 INCHES] COLOR [BLACK] ] DOG [BREED DOBERMAN HEIGHT [14 INCHES] COLOR [BLACK] ] Visible Logo objects like, Turtles, Bitmaps and Controls, all have properties assigned to them, which can be edited through property lists.

12 Arrays Special type of Logo object designed for efficient storage of structured information. Mostly thought of as tabular forms of information with multiple rows and columns. For example a calendar can be thought of as an array. You can write information to any particular day with three dimensions, year, month, and day. A special type of array is the bytearray, which can be used to store numerical information where each element is a number between 0 and 255.

13 Turtles A special type of graphics cursor. The turtle cursor carries a pen which can draw lines through commands issued in the listener window. The turtle can be controlled through commands such as: FORWARD, BACKWARDS, RIGHT, LEFT, PENUP, PENDOWN, and TOWARD.

14 Bitmaps Exactly what you think it is. An image which you can place anywhere in the Graphics window. The main difference between Bitmaps and Turtles, is that turtles can draw and are of only a single color, reflecting their pen color. Turtles visually reflect their heading, while bitmaps do not change visually when their heading is changed.

15 Controls Objects for obtaining input from the users for your program. A typical Control would be a push-button that you can click. You determine the size and position of the Control as well as what happens when the user interacts with the Control. Other examples of Controls are: Check boxes, scroll bars, pop-up menus, edit fields, and list boxes.

16 Variables Typical global and local variables. To declare local variables use LOCAL LOCAL “SALUTATION [HOW ARE YOU?] LOCAL “SALUTATION [HOW ARE YOU?] PRINT :SALUTATION HOW ARE YOU? HOW ARE YOU? To declare global variables use MAKE or NAME MAKE “GREETING “HELLO MAKE “GREETING “HELLO PRINT :GREETING HELLO NAME “HELLO “GREETING NAME “HELLO “GREETING PRINT :GREETING HELLO

17 Functions Created using the TO keyword. TO SQUARE REPEAT 4 [ FORWARD 50 RIGHT 90 ] To pass parameters just place them after the definition. TO SQUARE LENGTH REPEAT 4 [ FD LENGTH RT 90 ]

18 Conditionals IF IF expression [then-instructions] IF expression [then-instructions] [else-instructions] IF expression THEN instructions IF expression THEN instructions ELSE instructions IF expression [then-instructions] IF expression [then-instructions] [else-instructions] IF expression THEN instructions IF expression THEN instructions ELSE instructions TEST (has to be issued before IFTRUE and IFFALSE) TEST statement TEST statementIFTRUE IFTRUE instructionlist IFTRUE instructionlistIFFALSE IFFALSE instructionlist IFFALSE instructionlist

19 Loops REPEAT, FOR, EACH, FOREACH, WHILE REPEAT number list REPEAT number list REPEAT 5 PRINT [HELLO WORLD] ] FOR word number number runlist FOR word number number runlist FOR "I 1 4 [PRINT :I] EACH list EACH list EACH [SETH WHO * 360 / 16] EACH is controlled by WHO, and typically used for turtles EACH is controlled by WHO, and typically used for turtles FOREACH list runlist FOREACH list runlist FOREACH [JOHN MARTHA] [print "?] WHILE testlist runlist WHILE testlist runlist MAKE "X 1 WHILE [:X < 5] [PRINT :X MAKE "X :X + 1]

20 Multiple Turtles 16 possible turtles can be used at the same time CS TELLALL 0 15 SHOWTURTLE EACH [SETH WHO * 360 / 16];set direction EACH [FORWARD 8 * WHO] ;move based on id

21 More Turtles Turtles follow each other. TO SETUP CS SETTURTLES 4 TELL 0 PU SETXY [ 100 100 ];pen up TELL 1 PU SETXY [ -100 100 ] TELL 2 PU SETXY [ -100 -100 ] TELL 3 PU SETXY [ 100 -100 ] TELL ALLTURTLES ST PD;set pen down TO CHASE ASK 0 [SETH TOWARDS ASK 1 [GETXY] FD 1];FOLLOW 1 ASK 1 [SETH TOWARDS ASK 2 [GETXY] FD 1] ;FOLLOW 2 ASK 2 [SETH TOWARDS ASK 3 [GETXY] FD 1];FOLLOW 3 ASK 3 [SETH TOWARDS ASK 0 [GETXY] FD 1];FOLLOW 0 CHASE

22 RCX Commands To start communication with RCX RCX.OPEN port RCX.OPEN port RCX.OPEN “USB Motor control MOTOR number-or-list power MOTOR number-or-list power MOTOR number-or-list power duration MOTOR number-or-list power “FALSE Stop RCX execution RCX.HALT RCX.HALT Close communication RCX.CLOSE RCX.CLOSE

23 RCX Sensors Set sensor type SETSENSOR number type SETSENSOR number type SETSENSOR number type datatype SETSENSOR number type datatype slope Type can be SWITCH, TEMP, LIGHT, ANGLE Type can be SWITCH, TEMP, LIGHT, ANGLE :SENSORn is a built in variable for the sensor ports where n is 1-3. To read a sensor simply type.SENSORn and the value will be displayed in the Listener window.

24 RCX Limitations Logo does not provide full built-in support for the RCX. If you are familiar with the RCX byte codes you can directly program the RCX with.RCX list..RCX list sends direct byte codes to the RCX brick.

25 Blind Movement RCX.OPEN "USB TO RUN.UNTIL.HIT SETSENSOR 1 "SWITCH;set touch sensor MOTOR 3 65;move forward at 65 speed WHILE [.SENSOR1 = 0] [];while we don’t hit anything MOTOR 3 -50;when hit, reverse 50 MOTOR 1 -25;turn slightly WAIT 100;keep backing up MOTOR 1 25;realign the wheels WAIT 5 MOTOR 1 0;turn off turning motor RUN.UNTIL.HIT;recursively call self

26 References Terrapin Logo homepage: http://www.terrapinlogo.com http://www.terrapinlogo.com Logo Foundation website: http://el.media.mit.edu/logo- foundation/logo/index.html http://el.media.mit.edu/logo- foundation/logo/index.html Terrapin Reference Manual Terrapin Tutorial


Download ppt "Terrapin Logo "Logo is the name for a philosophy of education and a continually evolving family of programming languages that aid in its realization.""

Similar presentations


Ads by Google