Race to the Wall with Sensor (Extension)

Find a printable version of this page HERE.

Task Description

The goal is to get your robot as close to the wall as you can without touching it, as fast as you can, and have your Lego person remain standing on top of the robot for the entire race.

Use the ultrasonic sensor to \detect the robot’s proximity to the wall. 

  • Which robot was the fastest?
  • Which robot got the closest?
  • Whose Lego person remained standing?


  • The robot must start behind the start line.
  • Your Lego person must stand freely on the robot. They cannot sit nor can they be strapped or tethered in anyway.
  • The programming makes use of the sensor.

Materials Needed

  • EV 3 Robot in base configuration with the ultrasonic sensor attached. See Lego Building Instructions Manual pp. 42-47.
  • Masking tape to mark a starting line on the floor. The start line should be parallel and about 4-5 feet from a wall. 
  • 1 Lego person for each robot

Note for Teachers

  • Students learn attach a sensor to the robot and how to program it.
  • Note that the ultrasonic sensor can measure centimeters or inches.
  • Use this website to learn more about how to program the ultrasonic sensor: 
  • If the robot starts with too much power, the Lego person will fall off.

Programming Race to the Wall with Sensor


First, drag a <Move Tank Block> from the green tab on the lower menu.

Select <On>, which turns the driving motors on so that the robot approaches the wall. Choose appropriate power between 0 and 100.


Next, drag a <Wait Block> from the orange tab menu.

Select <Ultrasonic Sensor>, <Compare>, and <Distance Centimeter>.

Note: The ultrasonic sensor can also be programmed to detect inches.

Set the compare type to <Less Than>, and insert a suitable number of centimeters. 

In the example, once the ultrasonic sensor detects an object that is less than 10 cm away, the next block will be run.


Finally, drag a second <Move Tank Block> from the green tab menu, and select <Off> which will turn the driving motors off.

Please find a printable PDF here.

© 2020 Dr. Krista Francis & Stefan Rothschuh