Circuit Biscuits

Lesson 5 - Distance Sensing With HCSR04 Pupil Notes

The HC-SR04 sensor sends out an ultrasonic pulse and waits for the echo. The board measures the return time and uses that timing to work out distance.

In This Lesson

Lesson 5 Pupil Notes

Title

Distance Sensing With HC-SR04

Big Question

How can the board measure distance using sound instead of touch?

What This Lesson Is About

The HC-SR04 sensor sends out an ultrasonic pulse and waits for the echo. The board measures the return time and uses that timing to work out distance.

Key Words

  • distance
  • ultrasonic
  • echo
  • sensor
  • centimetres
  • timing

Before You Start

  • Open the sonar panel.
  • Keep the space in front of the sensor clear.
  • Be ready to move an object slowly closer and farther away.

What To Remember

  • the HC-SR04 sends out a sound pulse
  • the sound bounces back from an object
  • the board measures the return time
  • time can be turned into distance
  • live sensor values can drive display behaviour

What We Did

  • viewed live distance readings
  • moved objects closer and farther away
  • watched the value change in real time
  • linked distance values to display behaviour

What To Look For

  • how stable is the reading?
  • what happens when an object moves quickly?
  • what kinds of surfaces might give stronger or weaker echoes?

Try This

  • Hold an object still and note the reading.
  • Move it closer and watch the value change.
  • Move it away and compare the response.
  • Use the value in a rule or behaviour if available.

Why It Matters

This is a strong example of a real-world event becoming a number the system can reason about.

Check Yourself

  • What does the sensor send out?
  • What is an echo in this lesson?
  • Why does timing help measure distance?
  • Why might readings change when the object moves?

Reflection

  • A distance reading I saw:
  • What changed the reading:
  • One situation where this sensor would be useful: