Learning CS and Math with Robotics

CSP Unit 3 Lesson 5.7

Piano MinView
Linkbot Image Mindstorm Image
Grid Lines:
Tics Lines:
Width px
Hash Lines:
Width px
Font px
Trace Lines:
Robot 1:
Width px
Robot 2:
Width px
Robot 3:
Width px
Robot 4:
Width px
Simple View: Grid Size: S M L
CSP Unit 3 Lesson 5.7

Once we define a function, we can use it within other functions that we create. For example, it would be nice to have a "drawRectangle" function. To create one, take the code that draws a rectangle (as shown), which includes the traceOn, driveDistance, "right", and traceOff commands, and move it into a new function named drawRectangle using the pre-placed function block. Then add code that calls the drawRectangle function at the beginning of the program (after traceColor). Note that the function definition for "right" is pre-placed at the end for you.

Load Blocks
Workspace Show Ch Save File Console

Rubbish bin