Skip to main content

Lesson 4: Repeated Behaviors

In the previous Lesson, you observed how to use [If then] blocks in order for the VR Robot to check conditions. However, because of the flow of the project, the conditions within the [If then] blocks are only checked once. In this Lesson, you will be introduced to the [Forever] block and how it can be used to solve the Disk Maze Challenge.

The same diagram of the flow of logic in our VEXcode VR blocks project from the end of the last lesson. Arrows indicate that each if statement is checked only once, giving its internal blocks the option to run before the program's flow continues to the next if statement. After the last if statement is checked the flow of logic never loops back to check any of the if statements again, making the project much less responsive than we would like. Our project checks if the front eye detects green, and if so it turns right for 90 degrees. Next, if the front eye detects blue it turns left for 90 degrees. Next, if the front eye detects red it stops driving. Lastly, if the front eye detects none it drives forwards.

Learning Outcomes

  • Identify that the [Forever] block is a C block that repeats the behaviors inside of it forever.
  • Describe why a [Forever] block would be used in a project.
  • Describe the project flow in a VEXcode VR project that has multiple [If then] blocks inside of a [Forever] block.
  • Explain why [If then] blocks are used with [Forever] blocks.

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