Lesson 2: Drive to Green then Blue Disks
Drive to Green then Blue Disks
- The previous project has the VR Robot turn right when the Front Eye Sensor detects a green disk. Now, build a project where the VR Robot drives to four disks on the Disk Maze Playground.
- The goal is to create a consistent pattern where the VR Robot turns right when the Front Eye Sensor detects a green disk, and left when the Front Eye Sensor detects a blue disk.
- Add the following block to the existing project to instruct the VR Robot to drive forward after turning right.
- Add another [Wait until] with the <Color sensing> block set to detect ‘blue,’ since the next disk that the VR Robot will encounter is blue.
- Add a [Turn for] block and set the parameter to 'left.'
- Run the project to see how the VR Robot moves through the Disk Maze Playground.
-
Notice that the VR Robot turns right when the Front Eye Sensor detects a green disk, and turns left when the Front Eye Sensor detects a blue disk.
- Continue to build this project to drive the VR Robot to two more disks on the Disk Maze Playground using the Front Eye Sensor. Add the following blocks to navigate the VR Robot to the next two Disks then stop:
- Notice that there is a pattern. There is a series of blocks that are repeated three times in the project. This section of code can be condensed by using a [Repeat] block.
- Open the Disk Maze Playground if it is not already open, and run the project.
- Watch the VR Robot navigate to four disks on the Disk Maze Playground.
- In this project, the VR Robot drives forward until the Front Eye Sensor detects the color green.
- The VR Robot turns right 90 degrees and drives forward again until the color blue is detected.
- The VR Robot then turns left and drives forward until the Front Eye Sensor detects blue. Once the color blue is detected, the VR Robot turns left again.
- Finally, the VR Robot drives forward until the Front Eye Sensor detects blue, then stops.
- Notice the pattern that when the Front Eye Sensor detects green, the VR Robot turns right. When the Front Eye Sensor detects blue, the VR Robot turns left in this project.
Select the Next button to continue with the rest of this Lesson.