Skip to content

SensingSensors

Ultrasonic Distance

Sound goes out and back, so distance = speed of sound times time, divided by 2.

Not started Jump to practice

Bats find insects by listening for echoes. A cheap ultrasonic sensor does the same with a click too high for us to hear.

Key idea

The sensor sends a pulse of sound and times the echo. Sound goes there and back, so $d = \dfrac{v\,t}{2}$, with $v \approx 343\ \text{m/s}$ in room-temperature air. A closer formula is $v \approx 331 + 0.6\,T$ m/s, with $T$ in Β°C.
The robot uses its distance reading to stop before the wall.

Why it works

Sound is slow enough to time with a microcontroller: 1 meter away gives an echo after about 5.8 ms. Soft, angled or very small objects send back weak echoes, so these sensors can miss things a camera would see.

Worked example: Echo time to distance

An echo after 1,750 Β΅s.
  1. $343 \times 0.00175 \approx 0.600\ \text{m}$ round trip.
  2. Half: about 0.30 m.

Answer: About 30 cm.

Common mistake

Forgetting to halve the round trip, which makes every object look twice as far as it is.

Practice

Pass with 3 right answers, the last 2 in a row. Each right answer earns 2 XP.

Loading practice…

Builds on

Leads to

Sources and further reading

  • Roland Siegwart, Illah R. Nourbakhsh and Davide Scaramuzza, Introduction to Autonomous Mobile Robots, 2nd ed. (MIT Press, 2011)
  • Arduino Documentation