In the previous lesson we learned about repeat loops and used loop code to have the Linkbot trace out a square by drawing one side of the square each time around the loop. In this lesson we will add a second loop to the code from the previous lesson. Here's the plan: After the robot traces out the first square and returns to the origin at the point x=0, y=0, we will instruct the robot to move to a different on the grid by using a new command, the drivexyTo command: As you might guess from the name of the command, the drivexyTo command instructs the robot to drive in a straight line from wherever it is to the (x,y) point specified in the arguments to the command. For example, drivexyTo(2,2) will move the robot to the point (x=2,y=2) on the grid. So that's what we'll do. Then we'll instruct the robot to trace out another square of side length 5 by adding code blocks for a second repeat loop.
|
Grid Size: S M L | Simple View: | MinView: |
|
Coord: x-axis y-axis | Grid Lines: x-axis y-axis | |||
Grid: | 12x12 inches | 24x24 inches | 36x36 inches | |
72x72 inches | 96x96 inches | 192x192 inches | ||
1x1 inches | 2x2 inches | Fraction: | ||
xy-Range: | ||||
|
||||
|
||||
Quad: | 1 Quadrant | 4 Quadrants | 1&4 Quadrants | |
Units: | US Customary | Metric | Ruler: |
Labels: |
|
|
|
Font
px
|
|
Tics Lines: |
|
Width
px
|
Hash Lines: |
|
Width
px
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
(
,
in
) in
|
|
degrees
|
|
|
Problem statement here |
|
|
|||||||||||
|
|||||||||||