Thursday, July 31, 2014

Solutions: Drawing Polygons using Pro-Bot

Here is a subset of the possible solutions for drawing the polygons in this assignment. Please keep in mind that there are multiple correct ways of programming each of these figures.


The following programs draw the polygons without using Repeat Loops.

1. Square of sides 8 cm:
Fd 8
Rt
Fd 8
Rt
Fd 8
Rt
Fd 8
2. Rectangle 4 cm x 6 cm: 
Fd 4
Rt
Fd 6
Rt
Fd 4
Rt
Fd 6
3. Parallelogram 4 cm x 6 cm:
Fd 4
Rt 45
Fd 6
Rt 135
Fd 4
Rt 65
Fd 6
4. Rhombus 6 cm:
Fd 6
Rt 60
Fd 6
Rt 120
Fd 6
Rt 60
Fd 6
5. Equilateral Triangle of sides 6 cm:
Fd 6
Rt 120
Fd 6
Rt 120
Fd 6 
6. Right Triangle of sides 3 cm, 4 cm, 5 cm:
Fd 3
Rt 126
Fd 5
Rt 144
Fd 4 


Drawing Regular Polygons using Repeat Loops in Pro-Bot


All of the regular polygons below have sides of 6 cm.

1. Equilateral Triangle
Rpt 3 [
Fd 6
Rt 120
]
2.  Square
Rpt 4 [
Fd 6
Rt 90
// You can also use the instruction "Rt", instead of "Rt 90" in the code above,                                           // as the default turn is 90 degrees for Pro-Bot.
3. Pentagon
Rpt 5 [
Fd 6
Rt 72
]
4. Hexagon
Rpt 6 [
Fd 6
Rt 60
]
5. Octagon
Rpt 8 [
Fd 6
Rt 45
]
6. Nonagon
Rpt 9 [
Fd 6
Rt 40
7. Decagon
Rpt 10 [
Fd 6
Rt 36
]



A Circle using a Repeat Loop

Rpt 360 [
Fd 1                 // Move 1 cm
Rt 1                 // Turn 1 degree
]

An Algorithm for Drawing Regular Polygons using Repeat Loops 


From the pieces of code above for various regular polygons, the relation between the number of sides of a regular polygon and the angle of turn can be deduced to 360/N where N is the number of sides of the polygon.

The generalized algorithm for drawing regular polygons is:
Rpt N [
Fd X
Rt 360/N
]
where N is the number of sides of the regular polygon, X is the length of each side of the polygon.  



Drawing Polygons using Pro-Bot


In this programming assignment, we shall draw polygons using Pro-Bot. We shall start by using sequential programming to draw the polygons. Next, we shall look at some regular polygons and learn how to use Pro-Bot’s Repeat Loops to draw them. We shall also develop a generalized algorithm to draw regular polygons using Pro-Bot. We can store programs for the polygons as Procedures on Pro-Bot.



Computer Science concepts involved:  Sequential programming, Repeat loops, Algorithm development

Math concepts involved:  Polygons (regular and irregular), Linear & Angular Measurements, Interior angles, Supplementary angles

Grade levels:  3, 4, 5

Hours required:  3 or more



Polygons


In geometry, a polygon refers to a closed, two-dimensional figure formed by a set of straight line segments. The straight line segments are called the polygon’s edges or sides, and the points where two edges meet are the polygon's vertices or corners.

We see polygons of different types all around us in our daily lives. Here is an interesting article that I found on mathforum.org, as to where we see different types of polygons in our daily lives.

If all edges are equal and all angles are equal, then it is a regular polygon. Else, it is an irregular polygon.




Square:

Use Pro-Bot to draw a square of sides 8 cm. Each interior angle is 90 degrees.

Rectangle:

Use Pro-Bot to draw a rectangle of sides 4 cm and 6 cm. Each interior angle is 90 degrees.

Parallelogram:

Use Pro-Bot to draw a parallelogram of sides 4 cm and 6 cm. One pair of interior opposite angles is 45 degrees each and the other pair is 135 degrees each.


Note: Remember that for a parallelogram, opposite angles are equal. 
















In the figure of the parallelogram above, angles marked ‘a’ are equal; they are opposite angles. Similarly, angles marked ‘b’ are equal; they too are opposite angles. The angles ‘a’ and ‘b’ add up to 180 degrees; ‘a’ and ‘b’ are supplementary angles.

Note: Remember that when Pro-Bot has to draw a 45 degree interior vertex, it would have to turn 135 degrees and not 45 degrees, assuming it was moving in the forward direction before making the turn. Similarly for the 135 degree vertex, Pro-Bot would have to turn 45 degrees. Can you see why?

Rhombus:

Use Pro-Bot to draw a rhombus of sides 6 cm. One pair of opposite interior angles is 60 degrees each and the other pair is 120 degrees each. 

Next, use Pro-Bot to draw a rhombus of sides 6 cm. One pair of opposite interior angles is 90 degrees each. What shape do you get?

Equilateral Triangle:

Use Pro-Bot to draw an equilateral triangle of sides 6 cm. Each interior angle is 60 degrees.

Note: Remember that when you draw an equilateral triangle using Pro-Bot, at each vertex Pro-Bot has to turn 120 degrees (supplementary angle), and not 60 degrees, assuming it was moving in the forward direction before making the turn. Can you see why?

Right Triangle:

Use Pro-Bot to draw a right triangle of sides 3 cm, 4 cm and 5 cm. The interior angle between the 4 cm and 5 cm sides is 36 degrees. The interior angle between the 3 cm and 5 cm sides is 54 degrees. The interior angle between the 3 cm and 4 cm sides is 90 degrees.

Note: Remember that when you draw a right triangle using Pro-Bot, at each vertex Pro-Bot has to turn at its supplementary angle, and not the interior angle, assuming it was moving in the forward direction before making the turn. 



Drawing Regular Polygons using Repeat Loops in Pro-Bot


For the various shapes above that you drew using ProBot, you could see that in the case of programs for for the regular polygons (polygons with equal sides and equal interior angles), there is a pattern of instructions that keeps repeating multiple times. 

You can rewrite your programs for the square and the equilateral triangle using Repeat Loops in Pro-Bot. 


Use Pro-Bot to draw each of the shapes below. Use Repeat Loops to write your programs.
  1. Equilateral Triangle:   Use Pro-Bot to draw an equilateral triangle of sides 6 cm. Each interior angle is 60 degrees.
  2. Square:    Use Pro-Bot to draw a square of sides 6 cm. Each interior angle is 90 degrees.
  3. Pentagon:   Use Pro-Bot to draw a pentagon of sides 6 cm. Each interior angle is 108 degrees.
  4. Hexagon:    Use Pro-Bot to draw a hexagon of sides 6 cm. Each interior angle is 120 degrees.
  5. Octagon:    Use Pro-Bot to draw a octagon of sides 6 cm. Each interior angle is 135 degrees.
  6. Nonagon:   Use Pro-Bot to draw a nonagon of sides 6 cm. Each interior angle is 140 degrees.
  7. Decagon:   Use Pro-Bot to draw a decagon of sides 6 cm. Each interior angle is 144 degrees.

After drawing the various polygons, ask the students to identify a few examples of where they might see these shapes in their daily lives. For example: a sandwich cut in half is a triangle, roof trusses are triangles, a STOP sign is an octagon, a YIELD sign is a triangle, cells in beehives/ honeycombs are hexagons, etc.

Here is a set of solutions for this assignment.


Develop an Algorithm for drawing Regular Polygons using Pro-Bot


Now that you have written programs for Pro-Bot to draw various regular polygons, let us develop a generalized algorithm for the same.

  1. Is it more efficient to use Repeat Loops or Sequential Programming when you write programs for regular polygons on Pro-Bot?
  2. From your programs above, can you identify a technique to find the angle at which Pro-Bot should turn at each vertex for a regular polygon?
  3. Given the length of a side of a regular polygon and the angle you found using your above technique, can you write a program for drawing a regular polygon of N sides (N being any whole number) using Pro-Bot?
  4. Can you now generalize your method and write down the various steps involved, as an algorithm.


Experiment more with Regular Polygons using Pro-Bot:


  1. While developing your algorithm, did you notice that as the number of sides of the polygon increases, the shape of the polygon tends to a circle? What happens to the interior angle of the polygon in this case; does it increase or decrease?
  2. What happens to the angle at which Pro-Bot has to turn as the number of sides of the polygon increases? Does it increase or decrease?
  3. What is the smallest measurement of angle that you can use on Pro-Bot? What is the smallest length that you can draw using Pro-Bot?
  4. Using the algorithm that you developed above for Pro-Bot, draw a regular polygon using that uses the smallest angle and the smallest length that Pro-Bot can provide as its dimensions. What shape do you get? 
  5. Draw a regular polygon using Pro-Bot, just like the one in the previous question, that uses the smallest degree of angle, but with the length of the side increased by 1 unit. What shape do you get? 
  6. What happens to the shape if you keep increasing the length of the side by 1 unit at a time, but keep the angle constant at the smallest value?
  7. What happens if you increase both the length and the angle by 1 unit each time? What difference do you see?


Challenge Question

  1. Can you write a program for Pro-Bot to draw a circular maze (a spiral shape) using all of the ideas that you learned from the above questions? It is easier to start the spiral from inside and start moving outwards. Start the spiral with the smallest length and angle that Pro-Bot can provide and then build outwards.

Solutions: Art with Pro-Bot - A Soccer Game

The soccer game picture is a follow-up to the "Art with Pro-Bot: A Dancing Robot" exercise, with one of the figures being the exact same as the Dancing Robot and the other being its mirror image.


Let's name the figure on the left as Team A and the one on the right as Team B. You would recognize from the figure that both Team A and Team B share some parts in common, such as the head and the neck. So, it's easier for the programmer to write the code for these parts just once and store it as a procedure; it can then be used multiple times. 

// Proc 1 - procedure for the neck and head


Fd 1
Lt
Fd 1
Rt
Rpt 3 [
Fd 2
Rt
]
Fd 1





Team A:  


// Program written in Main and using the above procedure. The Start point is marked in the figure.


Rpt 4 [
Fd 10
Bk 4
Rt
]
Fd 3
Lt
Proc 1


Team B:


// Program written in Main and using the above procedure. The Start point is marked in the figure.


Rpt 4 [
Fd 10
Bk 4
Lt
]
Fd 3
Rt
Proc 1


Art with Pro-Bot: A Soccer Game


Let’s use Pro-Bot to draw a picture of robots playing soccer.

We shall work using both Repeat Loops and Procedures in Pro-Bot for this assignment. This "art" project was designed to use the concepts of Repeat Loops and Procedures in a fun way.

There are 2 robots in the picture, one representing Team 1 and the other, Team 2. The two robots are playing each other in a game of soccer. The dimensions are as follows: Each robot's body is a 6 cm side square, the limbs are 4 cm long, the neck is 1 cm long and the head is a 2 cm side square. 

While writing the programs for Pro-Bot to draw the figures, remember to use Repeat Loops for patterns that repeat. You can also see from the pictures that the head and neck is exactly the same for both pictures. Hence, you can write the program for the head and neck once, store it as a procedure in Pro-Bot's memory and call it for drawing both robots. 

Click here for a set of solutions.

Draw in as many members for each team as you like. You can even store the programs for each robot as separate procedures which makes it easier for you to draw multiple figures in your art project. You can put in a background of your choice and draw a soccer ball in the middle once you have drawn both teams. It does not have to be just soccer; students in my class have used this theme to depict scenes from various sporting events. We worked on this project the day after a major basketball game and there were quite a few children who made pictures with basketball scenes... Let your imagination run free in creating your art work. 























Programming Tangrams using Pro-Bot

This is a comprehensive programming project spanning over 4 hours, that aims to teach the key concepts that can be introduced via Pro-Bot (namely sequential programming, Repeat Loops and Procedures) while applying them to geometrical concepts that are covered in the classrooms. 
We shall make use of the famous tangram puzzles for this assignment. Let us take a quick look at what tangrams are and then talk about how to write programs for Pro-Bot to create them.   


Tangrams:


The tangram is a dissection puzzle consisting of seven flat shapes, called tans, which are put together to form shapes. The objective of the puzzle is to form a specific shape (given only an outline or silhouette) using all seven pieces, which may not overlap. It is reputed to have been invented in China and is one of the most popular dissection puzzles in the world.(Wikipedia)

Research shows that tangrams are helpful for developing an intuitive sense of geometry and developing visual-spatial skills. Tangrams have both geometric and artistic features. They help with classifying shapes, understanding the spatial rotation of shapes, understanding fractions, understanding the properties of various shapes including angles, area, perimeter, etc.


















To create a tangram, a square is divided up into 16 equal squares. Diagonal lines are drawn to produce 7 shapes. The seven pieces (numbered in the above picture) are:
2 large right triangles  (A, D)
1 medium right triangle (E)
2 small right triangles (C, G)
1 square (F)
1 parallelogram (B)

Some of the properties of the tans (puzzle pieces) are: 
  1. The large triangle is twice the area of the medium triangle. 
  2. The medium triangle, the square, and the parallelogram are each twice the area of a small triangle. 
  3. Each angle of the square measures 90 degrees. 
  4. Each triangle contains a 90 degree and two 45 degree angles (isosceles right triangles). 
  5. The parallelogram contains two 45 degree and two 135 degree angles. 
The relationships among the pieces enable them to fit together to form many figures and arrangements.



Now that we have taken a look at tangrams, let us write programs for Pro-Bot to draw the tangram puzzles.

We shall start by writing simple sequential programs to generate the seven individual puzzle pieces of the tangram. Then, we shall modify some of those programs to use Repeat Loops. We may also take a look at developing a generalized algorithm for drawing regular polygons (polygons with all sides equal and all angles equal) using Pro-Bot. Next, we shall learn to store programs for the individual puzzle pieces as Procedures in Pro-Bot’s memory, and then “call” them within programs that draw more complex tangram puzzles. 

Note that the programming questions are given in the order of increasing complexity, starting with simple polygons, then combining two or three of those to create compound figures and finally, creating complex tangram puzzles that use all seven pieces. 



Programming Assignment: 


Given a large square of sides 14 cm each, divide it into sections as shown in the figure below and create the 7 pieces of a tangram. Find the dimensions for each of the seven pieces. Make suitable modifications to the dimensions so that they can be used by Pro-Bot. Write programs to draw each piece separately using Pro-Bot. Finally, draw simple/complex tangram puzzles using Pro-Bot, making use of the programs that you wrote for the 7 tans/puzzle pieces.

Computer Science concepts involved:  Sequential programming, Repeat loops, Procedures/Sub-routines

Math concepts involved:  Polygons (Quadrilaterals, Triangles), Measurement, Fractions, Decimals, Rounding of decimal numbers, Angles, Trigonometry, Area, Perimeter, Congruence, Symmetry

Grade levels:  4, 5, 6

Hours required:  4 or more



Lesson Plan:

Hour 1:   Introduce Pro-Bot and tangrams. 

Allow the students to get familiarized with the Pro-Bot and its control panel. Introduce tangrams. Find out the dimensions of the 7 pieces in the tangram puzzle. Use sequential programming to create each of the 7 pieces in the tangram.

14 cm side square divided into 16 equal parts, 
with the diagonals drawn to create the seven puzzle pieces
























  • On a piece of paper, draw a square of sides 14 cm each.
  • Divide this 14 cm side square into 16 equal squares and trace all 7 shapes, using the above diagram as your guide.     
  • For the right triangles, either calculate the hypotenuse using the mathematical formula or measure it using a ruler.
  • Find the dimensions of the square and the parallelogram.
  • Can you figure out what fraction of the large square is taken up by each of the seven puzzle pieces?
  • Check to see if the dimensions obtained for the sides of the seven puzzle pieces are whole numbers or decimals. If they are decimal numbers, think about whether decimals can be used with Pro-Bot. If not, how can you adjust these numbers to work with Pro-Bot?
  • Once you have adjusted the dimensions so that they work on Pro-Bot, write programs to draw the puzzle pieces using Pro-Bot.
  • You can see that some of the puzzle pieces are congruent. Hence, you need to write the program only once for each set of congruent shapes.
  • Test your programs on Pro-Bot, one at a time to see if you get the desired results for each shape.



Hour 2:    Introduce Repeat Loops on Pro-Bot.
  • Now that all the puzzle pieces have been drawn using sequential programming, show how the programs for the square and the parallelogram can be rewritten using Repeat Loops in Pro-Bot. 
  • Write programs for drawing a few regular polygons using Pro-Bot (polygons with all sides equal and all angles equal) such as pentagon, hexagon, etc. Show how Repeat Loops can be used to write programs for these figures. Develop a generalized algorithm (a set of steps for solving a problem) for drawing regular polygons using Pro-Bot. 


Hour 3:    Introduce Procedures on Pro-Bot. Draw compound figures that use a subset of the seven puzzle pieces.
  • Store the program for each puzzle piece as a Procedure on Pro-Bot. Since the puzzle pieces would be used multiple times in the project, it makes it easier for you as the programmer, to write the program for each puzzle piece just once, store it as a Procedure and re-use it multiple times.
  • Work on a few compound figures that use a combination of just two or three of the puzzle pieces. Call the procedures for the individual puzzle pieces while writing programs for the compound figures.

A.   Write programs for Pro-Bot to draw the following compound figures that use the square and a small triangle from the tangram. 



























B.   Write programs for Pro-Bot to draw the following compound figures that use the parallelogram and two small triangles from the tangram. 





















C.   Your class is planning to do a gardening project. You have decided to grow spinach in an area measuring 12.5 square feet and carrots in 25 square feet. The two designs that you are considering for the garden are the ones in Question A above. Would you choose the square or the triangle part of the garden for the carrots? If the cost of fencing the garden is $5 per foot, which design would you choose so that the cost of fencing can be minimized.

D.   Your school has decided to pursue more vegetable gardening projects. This time, the plan is to grow tomatoes and peppers in spaces of equal area and carrots in a space that is double the area of tomatoes. The garden designs being considered are the ones in Question B above. Determine which vegetable would go in the parallelogram part of the garden and which ones would go in the triangles. How many square feet each of tomatoes, peppers and carrots can be grown? If the cost of fencing the garden is $5 per foot, which design would you choose so that the cost of fencing can be minimized.

E.   Can you make a trapezoid using just two pieces from the tangram? Write a program to draw your trapezoid using Pro-Bot.

F.   Can you make a parallelogram using just two pieces from the tangram? Write a program to draw your parallelogram using Pro-Bot.

G.   In each of the compound figures that you worked with, can you see the relationship between the angles of the puzzle pieces that allows them to fit together seamlessly?




Hour 4:    Write programs to draw complex tangram figures using Pro-Bot, using all seven puzzle pieces. You can choose either option A or option B.


Option A:
Create geometric shapes using all seven puzzle pieces of the tangram. Write programs for Pro-Bot that uses some of the Procedures for the puzzle pieces to draw the following figures. Compare the areas and perimeters among the complex figures that you create.

A.   Can you make a square that uses all 7 of the tangram pieces? Write a program to draw your square using Pro-Bot.

B.   Can you make a triangle that uses all 7 of the tangram pieces? Write a program to draw your triangle using Pro-Bot.

C.   Can you make a trapezoid that uses all 7 of the tangram pieces? Write a program to draw your trapezoid using Pro-Bot.

D.   Can you make a parallelogram that uses all 7 of the tangram pieces? Write a program to draw your parallelogram using Pro-Bot.

E.   How many squares can you make using some or all of the tangram puzzle pieces?


Option B:

You can find hundreds of artistic tangram puzzles on Google. Choose the designs that are the most interesting to you and work with them. Write programs for Pro-Bot that uses some of the procedures for the puzzle pieces to draw the figures that you choose.

Here is an example. Can you write a program for Pro-Bot to draw this figure, using some of the procedures that you previously created for the tangram pieces?

Wednesday, July 30, 2014

Solutions: Procedures: Revisiting Squares

The Procedures in Pro-Bot are pre-named from Proc1 to Proc32.


1.  Let's write the program for the square and store it in a procedure called Proc1. Access the New Proc or Edit Proc options from the Menu button to access the procedures and  choose Proc1. Here's what Proc1 might look like:

// Remember that you would see Proc1 as the first line on the screen here, not Main.

   Rpt 4 [
   Fd 6
   Rt
   ]


// To run this Procedure, go back to Main by clicking on the Menu button. Call Proc1 from Main using the Proc key and the number 1 on the control pad. Then press Go and watch your Procedure execute.



2.   Here is one way to use Proc1 from the above program to draw the stack of squares.

     Rpt 3 [
     Proc 1
     Fd 6
     Rt
     Fd 6
     Lt
     ]





3.   To draw the coaches for the train using Proc1, you could use the following code:
   
    Rpt 3 [
    Proc 1
    Rt
    Fd 8
    Lt
    ]

Procedures: Revisiting squares

The following programs are intended to provide practice with writing procedures in Pro-Bot, storing them in Pro-Bot's memory and calling them.


(1)  Write a program for Pro-Bot to draw a square of sides 6 cm. Store this program as a procedure on Pro-Bot (say proc1). Now call this procedure (proc1) from Main to test and see if Pro-Bot draws a 6 cm square.



(2)  Now that you have your program for drawing a 6 cm square stored in Pro-Bot's memory, any time you want to use it, you can call it either from your Main program or from another procedure.
You may recall the figure below from the Nested Loops assignment.




















Can you use the procedure that you have in Pro-Bot's memory to draw the above figure now? Rewrite your previous program for Pro-Bot to trace this figure, using the procedure for the square.




(3)   Let's revisit the Trains project from Nested Loops. Can you rewrite your previous program for Pro-Bot to draw the coaches of the train using the above procedure?




















In all of the projects above, you can see that you did not have to write the code for the square anew each time. All you had to do was write the program for the square once, store it as a procedure and then call the procedure any time you needed its functionality. You were able to use the same procedure for different programs.


Here is a set of solutions.

Procedures in Pro-Bot


Let’s start this lesson by taking a look at your typical school day. What are some of the functions that you perform on a given school day? Here are a few: you wake up, make your bed, brush your teeth, take a bath, get dressed, eat breakfast, travel to school, study, play, eat lunch, study again, travel home, play, sports/activities, watch TV, read a book, do homework, eat dinner, brush your teeth, sleep... If you look closely at each of these functions, you notice that each one of these involves multiple steps.

For example, brushing your teeth more or less involves the following steps: (1) pick up toothbrush (2) pick up toothpaste (3) squeeze the toothpaste onto the brush (4) actual brushing of the teeth (5) open the tap for water (6) fill up your glass (7) close tap (8) rinse your mouth (9) put away the toothbrush and toothpaste.

We bunched up all these steps and gave it a unique name: “brush teeth”. When your dad or mom wants you brush your teeth, do they say all these 9 steps one by one, or do they just say “brush teeth”? Why? Because you understand what “brush teeth” means. You have been taught in your younger days what that means and how to do all those 9 steps. All those steps are in your memory. So when you hear it, you know all the steps to do.

Now let us take a look at a computer… like your Pro-Bot. Don’t you think if a computer is first told how to draw a 6 cm side square, then each time you want to draw a 6 cm side square, you should be able to say a unique name like “square” or draw square”, or something like that, instead of telling it each time “Fd 6, Rt, Fd 6, Rt, Fd 6, Rt, Fd 6, Rt”? Guess what? The computer can do that! And that is what we call “Procedure”.

A procedure is a set of computer program instructions that performs a specific task.
  
In your daily life example, “brush teeth” is a procedure. It is a small group of instructions that performs a specific function. Any time your parent wants you to perform this function (which involves those 9 steps), he or she would just call it by the name “brush teeth”, rather than specify every step involved in it. This way, they get to reuse the “procedure” they taught you and made you memorize. Similarly, in a computer program, you write those steps once into the computer’s memory and give it a unique name. Then you can use it multiple times in your program.

Maybe, the dentist has advised you and your parents to include flossing into your routine. Flossing is also a procedure just like “brush teeth”. It involves some of these steps: (1) take the box of floss, (2) cut off about 10 inches of the flossing thread (3) coil it around your fingers (4) insert it between 2 of your teeth and pull (5) repeat this for all the gaps between your teeth (6) uncoil the string from your fingers (7) throw it into the garbage. Your parents work with you to teach you these steps until you have learned it. Then while brushing your teeth, he or she may remind you to “floss”. They don’t have to tell you all those 7 steps every time anymore. So here you can see that the “floss” procedure is called from within the “brush teeth” procedure.

Now let’s go back to the computer. Let’s say you want it to make a beeping sound after you draw the square. What would you do? You could write a procedure to make that beeping sound. Then call that “beep” procedure from within your “square” procedure after all those steps to draw the square. In this way, you just easily modified your first procedure to do something different.

Thus, you can call other procedures from within a procedure.

Back to our “brush teeth” example. You may decide to floss before you do other steps in your “brush teeth” procedure, or after you have done those steps. Similarly you may decide to make the Pro-Bot “beep” before it starts drawing the square instead of after drawing the square. Can you see how easy that would be? You just have to call the “beep” procedure first instead of last within your “square” procedure.

You can think of “school day” as a Program, and functions like “wake up”, “make bed”, “brush teeth”, etc., as Procedures inside the program. Now, try writing two different programs using the procedures for the daily functions: one program for a school day and the other program for a holiday. You can easily see that you would not call every one of the procedures for either program. There might be some procedures that are common to both programs and there might be some that are exclusive to each. Such as, you don’t “travel to school” on a holiday, but you “brush teeth” every day. You might also call them in different orders for the two programs. For example, you may watch TV at different times during a holiday, than on a school day.

Procedures thus help us to customize our programs easily.

We already mentioned that procedures and programs can call other procedures from within. They can be called multiple times as well. You can write a procedure for drinking water. You might call this procedure multiple times throughout the day, while performing other functions. This means that you can call “drink water” from within your “eat lunch” procedure or from within your “play” procedure or from within your “do homework” procedure, etc.


How to create and edit a procedure for Pro-Bot
Pro-Bot lets you create and store up to 32 procedures in its memory. In the case of Pro-Bot, these procedures are named Proc 1, Proc 2, …, …, Proc 32.
Pro-Bot’s Menu button provides two options to access procedures:
·      New Proc
·      Edt Proc

Let’s discuss each of these options.
1.   New Proc:
Press the Menu button & then scroll down to “New Proc”. Choose this option when you want to create a new procedure. It will show you a list of 32 procedures on the screen. Choose any procedure name from this list (Proc 1 to Proc 32). Let’s say that you choose Proc 3. Your Pro-Bot screen will now show Proc 3. Type in the instructions for the specific function that you want Proc 3 to perform. Next, press Menu. This will take you back to the Main program. You can now call Proc 3 from your Main program anytime you want to use it. You do this by pressing the “Proc” button and then the number key 3.

2.   Edt Proc:
Press the Menu button & then scroll down to “Edt Proc”. Choose this option when you want to edit a procedure that you created earlier. It will show you the list of 32 procedures on the screen. Choose the procedure that you want to edit from this list. Let’s say that you choose Proc 3. Your Pro-Bot screen will now show the instructions that you put in earlier for Proc 3 (or an empty program if you put in no instructions earlier). Make the changes that you want for this procedure. Next, press Menu to go back to the Main program. You can now call Proc 3 from your Main program and it will provide you with the updated functionality.

For example; you can write a procedure to draw a square of side 6 cm. Let’s say we name this procedure “Proc 1”. Proc 1’s code will be “Rpt 4 [ Fd 6   Rt ]”. You can store this procedure in memory and anytime you need to draw a 6 cm square, you just call Proc 1 from your Main program.


In addition to the 32 procedures that you can create and edit, Pro-Bot also provides 5 other procedures with pre-defined names related to the touch, light & sound sensors. You can edit these using the Edt Proc option from Menu. These procedures are:
·      33 FRONT (runs when the front touch sensor is triggered)
·      34 REAR (runs when the rear touch sensor is triggered)
·      35 DARK (runs when the light sensor goes from light to dark)
·      36 LIGHT (runs when the light sensor goes from dark to light)
·      37 SOUND (runs when the sound sensor is triggered)

There are also 3 built-in, pre-defined procedures that you cannot edit, but can call from Main. These are:
·      38 HEXGN: draws a hexagon
·      39 DIAMND: draws a diamond
·      40 FLOWER: draws eight diamonds using Proc39

Note: You can call other procedures from within any other procedure. Just take care not to run procedures that call each other, in which case you would get into an endless loop.