- :-

Topics Covered

  • Forward Until Near Behavior
  • Lesson Links

    Check Your Understanding:
    1. 1. If the robot is facing a wall, it will move until…
    2. The Distance Sensor has traveled 50 cm
      The Distance Sensor is 50 cm from the wall
      The robot moves 50 cm total
      The robot detects an obstacle beyond 50 cm away
    Mini Challenge

    Mini Challenge 1: Threshold Values

    The Wait - Ultrasoinc Sensor Block uses a "Threshold" to define what it is waiting for. Rather than look for a specific value (like 1cm or 200cm), it sets a "cutoff" value that divides all the possible Ultrasonic Sensor values into two catagories:

    • If the distance value is above the Threshold, it is considered "Far"
    • If the distance value is below the Threshold, it is considered "Near"

    • Place robot facing a wall that is more than 75cm away.
    • Write a program that runs toward a wall, and changes the LED color as gets closer:
      • Turn the light Green until the sensor detects the wall closer than 75cm
      • Then turn the light Orange until 50cm
      • Then turn the light Red until 25cm
      • Stop when the robot gets closer than 25cm

    Can't remember how to control the EV3's LEDs? Go to the LED Feedback Try It from Forward Until Near 3 for more details.

    Use multiple waitUntil commands in your program.

    Make sure your motor speed is low enough so the robot has time to display the different colors of the Touch LED Sensor.

    + hint
    Mini Challenge

    Mini Challenge 2: Move Until Far

    The program in the video above is Forward Until Near, meaning the robot will move forward until it detects a wall or object within the set threshold. Now, perform the opposite. Create a program that makes the robot back away from a wall or object until it is beyond the set threshold.

    • 1.Place robot near a wall, facing it.

    • 2.Program robot to back away until wall is 30cm away.

    Did You Know?

    Did you know?

    How the Ultrasonic Sensor works