- :-

Topics Covered

  • Using Sensor Data Values to Control a Robots Speed
  • Sensor Blocks
  • Using Loops to Update Values
  • Modifying the Move Steering Block
  • Lesson Links

    Check Your Understanding:
    1. 1. Why does the robot slow down as it approaches the wall?
    2. The number of centimeters gets smaller, and that smaller number is used as the Motor Power
      Placing an Ultrasonic Sensor Block anywhere in the program automatically executes this behavior
      The robot was running low of batteries as it was approaching the wall
      The Move Steering Block was told to run in a decreasing speed over time.
    3. 2. Why didn't the robot update the motor power in the first version of the program?
    4. The Move Steering Block prevented the Ultrasonic Sensor Block from running again
      The robot acted on its own accord
      Feedback from the Ultrasonic Sensor Block was only sent to the robot one time
      The Start Block was specifically set to run only once
    Try It!
    Try it! 1

    Looping On for Rotations

    What happens if you loop the behavior but leave
    the Move Steering Block in On for Rotations? Try it!

    What happens?

    The Move Steering Block will run with the sensor-set power, but it will “lock in” a power level for each one-rotation move. This is because the program doesn’t get to run the Read Sensor block again until the Movement block is done running.

    Try it! 2

    Big Delay

    If you put a big delay between the Sensor Block and the Move Steering Block, will the sensor from before or after the delay be used?

    1. Create the first version of the program (without the Loop)
    2. Add a Wait Block (for 5 second) in between the Ultrasonic Sensor and Move Steering Blocks
    3. Run the program above with your hand in front of the sensor at the start (low value), then move your hand away before the 5 seconds are up.

    Will the program use the low value from your hand, or the higher value from the wall? Try it!

    What happens?

    The reading is taken when the yellow Sensor Block is run, so it will use the low value from the beginning of the program.

    Mini Challenge

    Mini Challenge: Dangerous Wall

    You've created a program that slows the robot down as it approaches the wall. But what if you want to stop the robot before it touches the wall?

    Start from the program you created that makes the robot slows down as it approaches the wall.

    Add a feature that makes the robot plays a sound or or turn to the side
    when the robot reaches within 20 cm of the wall.


    Don’t try to use a Wait Block inside the loop, it will prevent the program from reaching the Sensor Block to take updated readings!

    What would happen if the program stopped repeating the commands?

    + hint