Skip to main content

Lesson 3: Using Conditionals

In the previous Lesson, you reached the end of the Disk Maze using the Eye Sensor and [Wait until] blocks. This Lesson introduces the [If then] block and how to use this block in the Disk Maze Challenge.

A top-down view of the Disc Maze playground, with an arrow showing the intended path of the VR robot. The robot should drive through the entire course, turning right at green disks and turning left at blue ones to finally reach the red disk goal. The order is 1 green disk, 4 blue disks, 1 green disk, 1 blue disk, 1 green disk, and then the final red disk.

Learning Outcomes

  • Identify that the [If then] block is a C block that runs the blocks inside of it if the Boolean condition is reported to be TRUE.
  • Identify that you can have multiple [If then] blocks in a project to be able check for multiple colors, and have multiple behaviors based on those colors.

Observing Patterns and Using Conditional Statements

In Lesson 2, a pattern was identified for the way the VR Robot must drive when a specific color is reported by the Eye Sensor on the Disk Maze Playground.

  • Front Eye Sensor detects ‘green?’
    • Turn right 90 degrees

      A top-down view of the Disk Maze playground, with the intended path of the VR robot marked with arrows. Each turn following a green disk is highlighted, indicating that a right turn always follows a green disk.
  • Front Eye Sensor detects ‘blue?’
    • Turn left 90 degrees

      A top-down view of the Disk Maze playground, with the intended path of the VR robot marked with arrows. Each turn following a blue disk is highlighted, indicating that a left turn always follows a blue disk.

This logic can be used to simplify the VEXcode VR Project with the [If then] block. [If then] blocks are conditional statements that instruct the VR Robot to make a decision if a specified condition is TRUE.

VEXcode VR If Then container block that has a space for blocks inside of it and a space for a boolean parameter.

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