Computer Science Level 1 - Blocks

Unit 6 - Knowing Your Location

# Lesson 2: Drive to Number ‘5’

In this Lesson, the VR Robot will drive to the number ‘5’ and back to the number ‘1’ on the Number Grid Map Playground!

Notice that the VR Robot will be traveling along the X axis with X values increasing to move to the number ‘5’ on the Number Grid Map Playground.

The VR Robot will drive to the location of the number ‘5’ on the Number Grid Map Playground. However, before the VR Robot can navigate to that number, the VR Robot has to be told where that number’s location is. Beginning at the center of the Playground, the coordinates of number ‘5’ are (-100, -900).

• To begin, the VR Robot needs to be facing the number ‘5.’ Drag in a [Turn for] block to the workspace.
• Drag the [Drive] non-waiting block into the workspace.
• Attach a [Wait until] block beneath the [Drive] block.
• The [Wait until] block accepts Boolean conditions. Just like the Distance Sensor Unit, this project will use the conditionals to drive through the Number Grid Map Playground. Drag the <Greater than> Boolean reporter block into the [Wait until] block.
• Note that the <Greater than> block is used instead of the <Less than> block because the VR Robot is driving to the right from the left side of the Playground. The VR Robot is starting at a X-value of -900 millimeters (mm). As the VR Robot drives forward, the X-values increase.
• Drag the (Position of Robot) block into the <Greater than> block.

The (Position of Robot) block is a numeric reporter block that reports the X or Y coordinate position of the center of the VR Robot. Choose whether the X or Y coordinate position is reported.

The (Position of Robot) block can report values in millimeters (mm) or inches.

• Set the parameter of the <Greater than> block to -100.
• Drag in a [Stop driving] block and add it to the project.
• Open the Number Grid Map Playground if it is not already open and run the project.
• Watch the VR Robot drive to number ‘5’ on the Number Grid Map Playground.
• In this project, the VR Robot drives to the number ‘5’ on the Number Grid Map Playground. The [Wait until] block is used so that the VR Robot will continue to drive forward until the X-value is greater than the X-value of the coordinate that the indicated number is on.
• Once the X-value is greater than -100, the project moves to the next block in the stack, which is a [Stop driving] block. Since the X-value of the number ‘5’ is -100, the VR Robot will stop driving once the X-value is greater than -100.

Select the Next button to continue with the rest of this Lesson.