Skip to main content

Lesson 3: Post-Project Summary

Why did the VR Robot continue driving when it reached the green disk?

When this project is run, the VR Robot continues to drive forward even when colliding with the first green disk, as is shown in the video below.

Video file

This project only instructs the VR Robot to check the conditions of each if else statement once at the beginning of the project.A diagram of the flow of logic in our VEXcode VR project. Arrows indicate that each if statement is only run once before the project ends, thus making our 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.

The if statement is different from the while loop

  • While loops do not require a decision to be made by the VR Robot. When the condition is True, the while loop with a not condition executes the next command outside the loop. When the condition is False, the while loop with a not condition continues to wait until the condition is True, and stops the rest of the project from running.
    Project flow diagram of a python project using a while not statement and a turn right command outside of the loop. A cyclic red arrow is shown to the right with the words: Continually checks condition, Front eye does not detect green, and Robot Drives forward. Beneath the red arrows is a green arrow with the words: Front eye does detect green, exits loop.
  • If statements require the VR Robot to make a decision. If the condition is True, then the commands inside the if statement are executed. If the condition is False, then the commands inside the if statement are not executed.
    Same project flow as the beginning of the page with the four sequential if statements and green arrows to the right. Beside each arrow is a question and answer. In order these read: Does Front Eye detect green? false. Does Front Eye detect blue? false. Does Front Eye detect red? False. Does Front eye detect no color? True drive forward.
  • The Front Eye sensor detects no color at the beginning of the project, thus the last if statement returns True. The VR Robot will continue to drive forward since the last if statement was reported as True and all other blocks were reported as False at the beginning of the project. 
  • Notice that there aren't any loops in this project that can pause the project flow to repeatedly check a condition. The if  statement checks the condition once, then moves on. 
  • Save the project before moving on to the next Lesson, to learn about adding repeatedly checking conditions with if statements.

Questions

Please select a link below to access the lesson quiz.

Google Doc / .docx / .pdf