- :-

Topics Covered

  • If/Else Block
  • Thinking About "Cases"
  • Lesson Links

    Check Your Understanding:
    1. 1. The robot will move forward...
    2. ...if there is no object in front of the Distance Sensor when the program starts.
      ...if there is an object in front of the Distance Sensor when the program starts.
      ...if an object passes in front of the Distance Sensor at any time.
      ...until an object passes in front of the Distance Sensor.
    3. 2. The robot makes its decision about whether to move forward or turn right...
    4. Once, when the If/Else Statement Block is reached in the program.
      Once, when the If/Else Statement Block sees an object
      Continually while the program is running
      The robot never moves, no matter what
    Mini Challenge

    Mini Challenge 1: Color Sensor Comparison

    The If/Else Conditional Block can use other sensors to make its decision as well!
    • Change the if-else conditional block to use the color value of the Color Sensor.
    • Put colored cards or different colored objects in front of the Color Sensor each time you run the program.
    • Program the robot to turn to the right if it sees green, and left if it sees any other color. The robot only needs to do this once per run, using the color it sees as soon as the program starts.

    Can't remember how to make Color Sensor detect colors? Review it again from Page 3 of the Color Sensor chapter.

    To make the robot make decision based on whether the object is green or not, set your if/else block to detect the color green.

    + hint