Skip to main content

Lesson 3: When Color Red Detected

There are no commands to tell the VR Robot what to do once it detects the color red. In order to avoid the red border, the VR Robot should reverse and turn once it detects the color red.

turn-when-detect-red
  • Add a [Drive for] and [Turn for] block to the end of the code to allow the VR Robot to reverse and turn once the Down Eye Sensor detects the color red.

Project with a drive for and a turn for block added
  • Open the Dynamic Castle Crasher Playground and run the project.

  • When this project is run, there are two conditions that are checked. The first is the condition of the Down Eye Sensor detecting the color red inside of the [Repeat until] block. Note that the project flow moves onto the next condition of an object being detected ONLY if the Down Eye Sensor does not see the color red. If the Down Eye Sensor does detect red, the project flow skips the [If then else] block and jumps to driving in reverse and turning.

Subtask 3
  • Once the Down Eye Sensor detects the color red, the VR Robot will drive in reverse, turn, then stop since that is the end of the project flow. There is no block used to repeat the behaviors again.

    no-forever-test
  • A [Forever] block is needed in order for the behaviors to repeat on a loop. Add a [Forever] block to the code.

Add a Forever block around the code.
  • Open the Dynamic Castle Crasher Playground and run the project.

  • When this project is run, the VR Robot will drive toward a detected building and turn right if no buildings are reported. Once the Down Eye Sensor detects the color red, the VR Robot drives in reverse, turns, and continues driving toward another building.

    lesson-3-run-project-last-time

Questions

Please select a link below to access the lesson quiz.

Google Doc / .docx / .pdf