How to programming the EV3 Ultrasonic sensor? Pro Preview

Now we will take our time and look at the wait block, when waiting for something to happen with the EV3 Ultrasonic sensor. There are similarities with the settings of the wait block in the other modes / sensors, but there are also few new settings.

To access the full video please subscribe to FLLCasts.com

Subscribe

  • #942
  • 17 Aug 2018

From the drop down menu of the wait block we select Ultrasonic Sensor. Then we choose "Compare" and then "Distance Centimeters". 

If you preffer working with inches, just select "Distance Inches" instead. There is no difference between the settings of the two, but for simplicity here we will be showing how to work with the centimeters mode only.

wait time block changed to wait ultrasonic block

 

The function of the Ultrasonic sensor is to measure the distance to objects. By default the ultrasonic sensor connects at port №4.

 

Choosing the measured distance threshold-value the robot should wait for

From the first dropdown menu we choose whether the robot to react at a distance:

 - equal to 50 cm (=);
 - different than 50 cm (≠);
 - longer than 50 cm (>);
 - longer than or equal to 50 cm (≥);
 - shorter than 50 cm (<);
 - shorter than or equal to 50 cm (≤).

Avoid the "equal to" option ( i.e. "=") as usually the robot passes the respective value too fast and fails to detect it and react as programmed.

In the example shown on the picture the value is set to 50 cm, but the sensor can detect distance between 3,01 cm and 255 cm.

 

Some information about metric units

Remember that 1 inch = 2,54 cm

A possible mistake is to forget to change inches to centimeters. This leads to giving incorrect instructions to the sensor which results in a failure of the program. The reason is that 10 inches are equal to 25 centimeters which is 2.5 times greater distance!

Courses and lessons with this Tutorial

This Tutorial is used in the following courses and lessons

Image for Robotics with LEGO - Level 1.0 - Adventure in Space
  • 126
  • 123:52
  • 150
Image for Lesson 5 - Ultrasonic sensor
  • 9
  • 5
  • 4
  • 3d_rotation 1
Image for Robotics with LEGO - Level 4.0 - Kinesthetic and Memory Game (in development)
  • 59
  • 2:58
  • 200
Image for Remember how to work with the ultrasonic sensor
  • 3
  • 0
  • 0
  • 3d_rotation 0
Image for Level A2. "Space exploration". Robotics with LEGO
  • 63
  • 3:02
  • 117
Image for Lesson 4 - Ultrasonic sensor
  • 5
  • 3
  • 3
  • 3d_rotation 1