Lesson: How Does an Ultrasonic Sensor Work?

Contributed by: GK-12 Program, Computational Neurobiology Center, College of Engineering, University of Missouri

Two images: A diagram shows a bat using its sonar to locate prey. The bat sends out sound waves and the returning waves provide it with information about the location of a moth. A photograph shows a palm-sized gray and white plastic device with a metal screens inside two orange-rimmed porthole openings (a LEGO ultrasound sensor).
Bats use echolocation to find and identify objects in their surroundings. To help robots identify objects, engineers have created ultrasonic sensors that operate using the same principles.
Copyright © (left) Wisconsin Department of Natural Resources; (right) 2006 Mark van Seeters, Wikimedia Commons http://dnr.wi.gov/eek/critter/mammal/wiscbat.htm http://commons.wikimedia.org/wiki/File:NXT_with_sensors.jpg


Students learn about how ultrasonic sensors work, reinforcing the connection between this sensor and how humans, bats and dolphins estimate distance. They learn the echolocation process—sound waves transmitted, bounced back and received, with the time difference used to calculate the distance of objects. Two mini-activities, which use LEGO® MINDSTORMS® NXT robots and ultrasonic sensors, give students a chance to experiment with ultrasonic sensors in preparation for the associated activity. A PowerPoint® presentation explains stimulus-to-response pathways, sensor fundamentals, and details about the LEGO ultrasonic sensor. Pre/post quizzes are provided. This lesson and its associated activity enable students to gain a deeper understanding of how robots can take sensor input and use it to make decisions via programming.

Engineering Connection

Biological engineers and neuroscientists perceive the human body as a functioning, controlled system, similar to a robot. Research findings are showing that mathematical principles similar to those used in robotics are extremely useful or even necessary for a complete understanding of the human body. Through this lesson, students strengthen their understanding of the functioning of each of the human (and bat) senses by relating them to the different sensors used in robots. Ultrasonic sensors are used in medicine to detect shapes and sizes of otherwise unseen internal body parts. For instance, doctors can determine gender of a fetus in the womb of its mother. Ultrasonic sensors are also used to determine wind speed and direction. Sonar and radar technologies are based on the same concepts.

Pre-Req Knowledge

Learning Objectives

After this lesson, students should be able to:

  • Describe how ultrasonic sensors work.
  • Compare the ultrasonic sensor to how humans and bats estimate distance.
  • Program the LEGO MINDSTORMS NXT robot with the ultrasonic sensor.
  • Provide a basic explanation of how sensors are integrated into robots via careful programming.

More Curriculum Like This

How Do You Make Loops and Switches?

Students learn how to program using loops and switches. Using the LEGO® MINDSTORMS® robots, sensors and software, student pairs perform three mini programming activities using loops and switches individually, and then combined.

How Do You Make a Program Wait?

Building on the programming basics learned so far in the unit, students next learn how to program using sensors rather than by specifying exact durations. They start with an examination of algorithms and move to an understanding of conditional commands (until, then), which require the use of wait bl...

What Are Gears? What Do They Do?

Students are introduced to an important engineering element—the gear. Different types of gears are used in many engineering devices, including wind-up toys, bicycles, cars and non-digital clocks. Students learn about various types of gears and how they work in machines.

How Do Sensors Work?

Through six lesson/activity sets, students learn about the functioning of sensors, both human and robotic. The overall framework reinforces the theme of the human body as a system with sensors—that is, from an engineering perspective.

Elementary Unit

Educational Standards

Each TeachEngineering lesson or activity is correlated to one or more K-12 science, technology, engineering or math (STEM) educational standards.

All 100,000+ K-12 STEM standards covered in TeachEngineering are collected, maintained and packaged by the Achievement Standards Network (ASN), a project of D2L (www.achievementstandards.org).

In the ASN, standards are hierarchically structured: first by source; e.g., by state; within source by type; e.g., science or mathematics; within type by subtype, then by grade, etc.

  • Use argument supported by evidence for how the body is a system of interacting subsystems composed of groups of cells. (Grades 6 - 8) Details... View more aligned curriculum... Do you agree with this alignment?
  • Gather and synthesize information that sensory receptors respond to stimuli by sending messages to the brain for immediate behavior or storage as memories. (Grades 6 - 8) Details... View more aligned curriculum... Do you agree with this alignment?
  • Solve problems involving measurement and conversion of measurements from a larger unit to a smaller unit. (Grade 4) Details... View more aligned curriculum... Do you agree with this alignment?
  • Convert among different-sized standard measurement units within a given measurement system (e.g., convert 5 cm to 0.05 m), and use these conversions in solving multi-step, real world problems. (Grade 5) Details... View more aligned curriculum... Do you agree with this alignment?
  • Various relationships exist between technology and other fields of study. (Grades 3 - 5) Details... View more aligned curriculum... Do you agree with this alignment?
  • Knowledge gained from other fields of study has a direct effect on the development of technological products and systems. (Grades 6 - 8) Details... View more aligned curriculum... Do you agree with this alignment?
  • Describe how new technologies have helped scientists make better observations and measurements for investigations (e.g., telescopes, magnifiers, balances, microscopes, computers, stethoscopes, thermometers) (Grade 4) Details... View more aligned curriculum... Do you agree with this alignment?
  • Describe how new technologies have helped scientists make better observations and measurements for investigations (e.g., telescopes, electronic balances, electronic microscopes, x-ray technology, computers, ultrasounds, computer probes such as thermometers) (Grade 5) Details... View more aligned curriculum... Do you agree with this alignment?
  • Explain the interactions between the nervous and muscular systems when an organism responds to a stimulus (Grade 8) Details... View more aligned curriculum... Do you agree with this alignment?
Suggest an alignment not listed above


(Be ready to show students the 19-slide How Does an Ultrasonic Sensor Work? Presentation, a Microsoft® PowerPoint® file, to teach the lesson. In advance, make copies of the Ultrasonic Sensor Pre-Quiz and Ultrasonic Sensor Post-Quiz, one each per student, provided as attachments and slides. For the mini-activities, student pairs use LEGO robot components to experiment with the sensors.)

Today we are investigating another sensor—the ultrasonic sensor. Have you heard of an ultrasonic sensor? This sensor is able to estimate objects in front of it using reflected sound. Does this process sound similar to any other process you know of? (Listen to student ideas. They may mention bats, echolocation, radar or sonar). This process is similar to how bats locate objects in their paths.

Our lesson includes two mini-activities to help us get familiar with the LEGO NXT ultrasonic sensor. Then in the next class, we will conduct a more-involved activity that gives you the opportunity to program your LEGO robots to move about freely without bumping into LEGO people. To do that, you'll use a LEGO NXT ultrasonic sensor to detect whether anything is in the way.

(Continue by showing the presentation and delivering the content in the Lesson Background section.)

Lesson Background and Concepts for Teachers

Present the lesson using the content provided in the slide presentation, as described below. The quizzes are embedded in the presentation if you wish to go through them as a class. During the lesson, students engage in two mini-activities (slides 11-12) that require the following items for each student pair:

How Does the Ultrasonic Sensor Work? Presentation Outline (Slides 1-19)

  • Administer the pre-quiz by handing out paper copies; the quiz is also on slide 2. The answers are provided for the teacher on slide 3 for discussion after students have completed the quiz.
    A photograph shows a palm-sized gray and white plastic device with a metal screens inside one orange-rimmed porthole opening.
    One of the "eyes" of the NXT ultrasonic sensor.
    Copyright © 2009 Christian Reitter, Wikimedia Commons http://commons.wikimedia.org/wiki/File:Lego_mindstorms_nxt_ultrasonic_sensor.jpg?uselang=et
  • (slide 4) Explain the structure of the LEGO NXT ultrasonic sensor. (Hold up an ultrasonic sensor to show students.) It has two main parts. A transmitter sends out a signal (an ultrasonic wave) that humans cannot hear. And a receiver receives the signal after it has reflected off nearby objects. The sensor times how long it takes for its signals to come back and relays that information to the LEGO brick/computer, which calculates how far away objects are. Ask the students: Does this process sound familiar? Do you know of any animal that are able to sense in a similar way? (Answer: Bats, dolphins, porpoises and some whales use echolocation, sometimes called biosonar.)
  • (slides 5-7) How does a bat locate its prey in the dark? Explain how bats use echolocation to measure distance and the similar process with a robotic sensor. The time difference between sending and receiving is used to estimate distance.
  • (slide 8) Provide an overview of robotic sensors to keep emphasizing the big picture.
    A line drawing shows a sender/receiver device on the left sending sound waves towards an object at distance r to the right. Reflected sound waves from the object return to the receiver.
    Measuring distance using the echolocation concept.
    Copyright © 2005 Georg Wiora, Wikimedia Commons http://commons.wikimedia.org/wiki/File:Sonar_Principle_EN.svg
  • (slide 9) Go into the details of the same concepts, but with some specifics on measuring distance. The ultrasonic sensor can measure distances in centimeters and inches. It can measure from 0 to 2.5 meters, with a precision of 3 cm. It provides good readings in sensing large-sized objects with hard surfaces, but has more difficulties reading reflections from soft, curved, thin or small objects.
  • (slide 10) The ultrasonic sensor sends out sound from one side (one of the "eyes") and receives it back using the sensor on the other side. Together, the ultrasonic sensor's transmitter and receiver look like a pair of eyes, but it is not a sight sensor. Instead, those "eyes" are really more like a speaker and a microphone (a sound sensor).
  • For the mini-activities, divide the class into pairs and give each pair a LEGO NXT ultrasonic sensor, motor, intelligent brick and two cables. Direct student pairs to follow the instructions on slides 11-12 to experiment with the NXT ultrasonic sensor.
  • (slide 11) In the first activity, they spend ~10 minutes using the ultrasonic sensor connected to the brick to study how the sensor works and what it does. Make sure they do the "Try Me" option and write down their observations from their experimentation.
  • (slide 12) In the second activity, they add the motor to the setup and spend ~15 minutes programming the LEGO robot so that it plays one music when an object is close to it (less than 10 inches), and keeps the motor turning. If the object is farther than 10 inches, have the program stop. On a separate sheet of paper, have students provide step-by-step explanations describing how the program works. The programming solution is provided for the teacher on slides 13-16.
  • Administer the post-quiz by handing out paper copies; the quiz is also on slide 17. The answers are provided on slide 18. This concludes the lesson. Slide 19 contains vocabulary terms and definitions. Next, conduct the associated activity.


auditory: Related to hearing.

echolocation: Biological sonar used by animals, such as bats and dolphins, in which the animal sends out a call and uses the echo to locate and identify surrounding objects.

peripheral: Surrounding.

sensor: A device that converts one type of signal to another; for instance, the speedometer in a car collects physical data and calculates and displays the speed the car is moving.

transducer: Another term for a sensor.

ultrasonic: A sound that we cannot hear, but bats and dogs can hear.

Associated Activities

  • Don't Bump into Me! - Student groups program LEGO robots outfitted with ultrasonic sensors to meet a design challenge: Enable the robot to roam around freely without bumping into the toy people obstacles. They practice and learn programming skills and logic design in parallel, seeing how robots take input from ultrasonic sensors and use it to make decisions to move, similar to echolocation. They iterate their designs to success.

Lesson Closure

Engineers were inspired by how bats estimate distance to objects in their surroundings to design the ultrasonic sensor. Robots use sensors to make decisions about movement and actions in much the same manner as humans do to control their muscles and bodily functions.



Pre-Lesson Assessment

Pre-Quiz: Administer the three-question Ultrasonic Sensor Pre-Quiz by handing out paper copies (also on slide 2). Students' answers reveal their base knowledge of ultrasonic sensors, as well as how humans and bats estimate distances. Have students answer as best as they can. Answers are provided in the Ultrasonic Sensor Pre-Quiz Answer Key (and on slide 3).

Post-Introduction Assessment

Hands-On Learning: Observe all students as they engage in the mini-activities described on slides 11-12. Make sure all pairs are following the slide instructions to experiment with the ultrasonic sensor. Question individual students to verify that they understand how the ultrasonic sensor works. Compare groups' programming answers to the teacher solution provided on slides 13-16. Review their written observations and programming answers to gauge their comprehension of the topic and readiness for the associated activity.

Lesson Summary Assessment

Conversion Practice: Have students practice unit conversions as they convert the following example ultrasonic sensor distance readings from centimeters to inches and vice versa:

  • 5 cm = _____ inches (1 cm = ~0.394 inches --> 5 cm x 0.39 = 1.97 inches)
  • 3 cm = _____ inches (1.18 inches)
  • 2 inches = _____ cm (1 inch = 2.54 cm --> 2 in. x 2.54 = 5.08 cm)
  • 4 inches = _____ cm (10.16 cm)

Post-Quiz: Administer the Ultrasonic Sensor Post-Quiz by handing out paper copies (also on slide 17). Review students' answers to assess their understanding, as well as how much they learned during the course of the lesson. Quiz answers are provided on the Ultrasonic Sensor Post-Quiz Answer Key (and on slide 18).

Additional Multimedia Support

NXT robots and sensors: http://mindstorms.lego.com/eng/Overview/default.aspx

What is a transducer? http://en.wikipedia.org/wiki/Transducer

What is a sensor? http://en.wikipedia.org/wiki/Sensors

List of sensors http://en.wikipedia.org/wiki/List_of_sensors


Nishant Sinha, Pranit Samarth, Satish S. Nair


© 2013 by Regents of the University of Colorado; original © 2013 Curators of the University of Missouri

Supporting Program

GK-12 Program, Computational Neurobiology Center, College of Engineering, University of Missouri


This curriculum was developed under National Science Foundation GK-12 grant no. DGE 0440524. However, these contents do not necessarily represent the policies of the National Science Foundation, and you should not assume endorsement by the federal government.

Last modified: April 26, 2017