Arduino Learning Studiorobotics pathway

R10-U2 · usually age 10 · Robot Explorers

Measure Distance

How does a robot know something is near?

Pilot unit plan · 5 sessions · not yet classroom-validated

Build: Digital parking-distance display

A distance sensor times an echo, and its block turns the time into a distance with a unit. Learners compare the 3.3 V-safe sensor with a ruler, read the same distance in microseconds, centimetres and inches, find what a 0 means, calibrate against the ruler, and build a digital parking-distance display whose readings they check against the ruler.

  • Sense
  • Test and debug

Who it is for

Age is a starting point, never a limit. A learner who can show what this unit starts from can begin here at any age.

How they learn
By arranging instruction cards or blocks, predicting what happens, and testing on a kit. Short sentences, with words and pictures together.
The adult's role
An adult oversees circuits, batteries and motors.
Session
60–75 minutes
Hardware
micro:bit with MakeCode, or a similar child-friendly board. Start in the board's own simulator. A micro:bit is 3.3 V: never connect a 5 V signal straight to it.

Starts from

Builds, and what it is the input for

In the studio today

No studio lab or activity for this unit yet.

Sessions

  1. Session 1 · 60 min

    How can an echo tell us how far away something is?

    A distance sensor sends a short burst of ultrasound and times its echo: a longer wait means a farther object. The ruler is the reference, in centimetres. In the simulator the distance block cannot measure: it always gives the same made-up number.

    The adult says first: “A sensor can time an echo. A far echo comes back later.”

    Learner card

    1. Walk to the wall and back.
    2. Far takes longer.
    3. Measure the box with a ruler.
    4. Write cm after each number.
    5. The simulator cannot measure.

    Key words (show each with a picture): echo · distance · centimetre

    Timing (15 of 60 min at the screen)

    1. 15 minAway from the screen: Echo walk: to the wall and back from 1 m and from 2 m; which trip takes longer?
    2. 10 minAway from the screen: Measure the box at 10, 20 and 30 cm with a ruler; write cm.
    3. 15 minAt the screen: MakeCode: add the sonar extension; the distance in “show number” in “forever”; read the simulator's number.
    4. 10 minAway from the screen: Draw the table; guess what the real sensor will say.
    5. 10 minAway from the screen: Say why the simulator's number is not a measurement.

    In the studio

    No studio lab or activity.

    Outside the studio: MakeCode editor and its micro:bit simulator (makecode.microbit.org)

    Hands-on

    Nothing is powered: this session uses rulers, a box and the simulator only. First, away from the screen, the group plays echo: one learner walks from a start line to a wall and back at a steady pace while the others count, from 1 m and then from 2 m away, and says which trip took longer. Then each pair measures a box at 10, 20 and 30 cm from a line with a 30 cm ruler, writing each number with cm. In MakeCode next, the adult adds the sonar extension; the learner puts the “ping trig P1 echo P2 unit …” block, set to cm, inside “show number”, inside “forever”. In the simulator the distance block always gives the same made-up number (86 in cm): it has no sensor, so it cannot measure. The learner guesses what the real sensor will say for each box.

    Starting blocks: Built from scratch: “forever” holding “show number”, with “ping trig P1 echo P2 unit …” set to cm inside it.

    Evidence to collect

    A prediction for each box position, the learner's own short test table (Box at (cm) | My guess | Simulator shows) for 10, 20 and 30 cm, and the learner's spoken explanation of why the simulator's number is not a measurement.

    Test table columns: Box at (cm) | My guess | Simulator shows

    Predict
    Before the simulator runs, the learner guesses the number it will show.
    Debug
    If the sonar block is missing, check that the sonar extension was added in Extensions on this computer.
    Reflect
    Why is the ruler the one to trust today?

    Works towards: Distance sensing

  2. Session 2 · 75 min

    How far away is the box, says the sensor?

    The real sensor, wired by the adult with everything switched off: an RCWL-1601 powered from the Link header's 3V pin, so its signals are 3.3 V, safe for the micro:bit. Trig on P1 sends the sound; Echo on P2 brings back how long it took; the block turns that time into centimetres. The ruler's 0 is at the sensor's front face.

    The adult says first: “Now the real sensor measures. Compare it with the ruler.”

    Learner card

    1. Put the box at 10 cm.
    2. Guess the sensor's number.
    3. Read the display.
    4. Write both numbers.
    5. Try 20, 30 and 40.

    Key words (show each with a picture): sensor · ruler · compare

    Timing (10 of 75 min at the screen)

    1. 10 minAway from the screen: With the board off: which wire sends, which listens, and which brings the 3V?
    2. 10 minAt the screen: The session 1 blocks in the simulator, then download.
    3. 10 minAway from the screen: Mark the strip every 10 cm from the sensor's front face; stand the box with a flat side to the sensor.
    4. 30 minAway from the screen: Readings at 10, 20, 30 and 40 cm, each guessed first.
    5. 15 minAway from the screen: Fill in the table; say how close the sensor and the ruler were.

    In the studio

    No studio lab or activity.

    Outside the studio: MakeCode editor and its micro:bit simulator (makecode.microbit.org)

    Hands-on

    Before the session, with the board and the holder switched off, the adult wires the sensor to the Link header: VCC to the Link header's 3V, GND to GND, Trig to P1 and Echo to P2, with four female-to-female jumper wires on the header pins the adult soldered in. In the simulator first, the learner checks the session 1 blocks; then the learner downloads them (the board switched off, the micro:bit out of the board, USB in; USB out once the light on the back stops flashing, the micro:bit back in). The sensor stands at the start of a 50 cm strip of masking tape marked every 10 cm, facing along it, with the strip's 0 (the ruler's 0) at the sensor's front face, and a box stands on the strip with a flat side facing the sensor. The adult switches on. The learner sets the box at 10, 20, 30 and 40 cm, guesses each reading, then reads the display and writes both numbers.

    Starting blocks: The learner's session 1 blocks (the distance in “show number” in “forever”).

    Pins

    P1
    distance sensor Trig
    P2
    distance sensor Echo

    Evidence to collect

    A prediction for each position, the learner's own short test table (Ruler (cm) | My guess (cm) | Sensor (cm)) for 10, 20, 30 and 40 cm, and the learner's spoken explanation of how close the sensor and the ruler were.

    Test table columns: Ruler (cm) | My guess (cm) | Sensor (cm)

    Predict
    Before each position, the learner guesses the sensor's number in cm.
    Debug
    If the display shows 0, the sensor heard no echo: turn the box to face it squarely, then check the wiring with the board switched off.
    Reflect
    Was the sensor closer to the ruler for a near box or a far box?

    ⚠ Adult checks before power-on: Nothing metal touches the micro:bit, its gold pins or the board, and nothing metal lies under it. Before the adult switches on: the micro:bit is firmly in the board, display facing the Link header, its own battery pack and USB unplugged; both switches were off while anything was plugged in or moved. The distance sensor is an RCWL-1601, sold for 3 V or 5 V but never powered from 5 V here: it runs from the Link header's 3V pin, so its Echo signal is 3.3 V. Never a 5 V-only HC-SR04. Plastic toy vehicles only near the board; nothing metal on or under it. Rewire only when unpowered: the board and the holder are switched off before any wire, motor, servo or sensor is plugged in, moved or taken out.

    Works towards: Distance sensing

  3. Session 3 · 75 min

    What do the units mean?

    The same distance in three units: the block gives microseconds (μs, how long the echo took), centimetres or inches. It divides the time by 58 for centimetres and by 148 for inches, keeping whole numbers. A 0 means no echo came back in time, and the sensor cannot see closer than about 2 to 3 cm: there it may show 0 or a wrong number.

    The adult says first: “One distance can have many numbers. The unit tells you which.”

    Learner card

    1. Change the unit on the block.
    2. Guess: bigger or smaller?
    3. Read μs, then inches.
    4. A 0 means no echo.
    5. Write the unit every time.

    Key words (show each with a picture): unit · microsecond · inch

    Timing (20 of 75 min at the screen)

    1. 10 minAway from the screen: Guess: is the μs number bigger or smaller than the cm number? And inches?
    2. 10 minAt the screen: Change the unit to μs; the simulator, then download.
    3. 15 minAway from the screen: Readings at 10 and 30 cm in μs.
    4. 5 minAt the screen: Change the unit to inches; download.
    5. 10 minAway from the screen: The same two readings in inches.
    6. 5 minAt the screen: Back to cm; download.
    7. 10 minAway from the screen: Too close (1 cm), and a soft jumper at 20 cm.
    8. 10 minAway from the screen: Fill in the table; say what each unit means and what a 0 means.

    In the studio

    No studio lab or activity.

    Outside the studio: MakeCode editor and its micro:bit simulator (makecode.microbit.org)

    Hands-on

    In the simulator first, the learner changes the block's unit to μs and checks the blocks (the simulator shows its made-up 5000 μs); then the learner downloads them (the board switched off, the micro:bit out of the board, USB in; USB out once the light on the back stops flashing, the micro:bit back in), and the adult switches on. With the box at 10 and at 30 cm, the learner reads μs. Then the unit changes to inches, tried in the simulator and downloaded the same way, and the learner reads the same two positions. Last, back in cm, the learner tries the box 1 cm from the sensor and a soft jumper held by the adult at 20 cm, and says what a 0 means. The adult says first that at 1 cm, inside the blind spot, the display may show 0 or a wrong number that is not 1: neither can be trusted there.

    Starting blocks: The learner's session 2 blocks, with the unit changed on the distance block.

    Pins

    P1
    distance sensor Trig
    P2
    distance sensor Echo

    Evidence to collect

    A prediction for each reading, the learner's own short test table (Ruler (cm) | Unit | My guess | Reading) for two positions in μs and inches and two hard cases in cm, and the learner's spoken explanation of what each unit measures and what a 0 means.

    Test table columns: Ruler (cm) | Unit | My guess | Reading

    Predict
    Before each unit, the learner guesses whether its number will be bigger or smaller than the cm reading.
    Debug
    If μs and cm seem to disagree, divide the μs by 58 (a calculator is fine): the block's cm is that answer without its remainder.
    Reflect
    Why do we always write the unit after a distance?

    ⚠ Adult checks before power-on: Nothing metal touches the micro:bit, its gold pins or the board, and nothing metal lies under it. Before the adult switches on: the micro:bit is firmly in the board, display facing the Link header, its own battery pack and USB unplugged; both switches were off while anything was plugged in or moved. The distance sensor is an RCWL-1601, sold for 3 V or 5 V but never powered from 5 V here: it runs from the Link header's 3V pin, so its Echo signal is 3.3 V. Never a 5 V-only HC-SR04. Plastic toy vehicles only near the board; nothing metal on or under it. Rewire only when unpowered: the board and the holder are switched off before any wire, motor, servo or sensor is plugged in, moved or taken out.

    Works towards: Distance sensing

  4. Session 4 · 75 min

    How do we make the sensor agree with the ruler?

    Calibration: compare the sensor with a trusted reference (the ruler, its 0 at the sensor's front face) at several distances and find the difference each time, sensor minus ruler. The block drops the remainder, so even a perfect sensor can read up to 1 cm less than the ruler: a difference of 0 or −1 cm is expected. If a bigger difference stays about the same, it is the correction; if it grows with distance, one number will not fix it. Steady readings first: one odd reading is not a pattern.

    The adult says first: “Calibrate means checking against something you trust. Our ruler is the reference.”

    Learner card

    1. Read five distances.
    2. Sensor minus ruler.
    3. Is the difference the same?
    4. Write your correction card.
    5. Test 30 cm three times.

    Key words (show each with a picture): calibrate · difference · reference

    Timing (10 of 75 min at the screen)

    1. 10 minAway from the screen: Guess: will the sensor read more than the ruler, less, or the same?
    2. 10 minAt the screen: The cm blocks in the simulator, then download.
    3. 30 minAway from the screen: Five distances; then 30 cm three times and the box at an angle.
    4. 10 minAway from the screen: Work out each difference: sensor minus ruler (0 or −1 is expected).
    5. 15 minAway from the screen: Write the correction card; say when it can be trusted.

    In the studio

    No studio lab or activity.

    Outside the studio: MakeCode editor and its micro:bit simulator (makecode.microbit.org)

    Hands-on

    In the simulator first, the learner checks the cm blocks; then the learner downloads them (the board switched off, the micro:bit out of the board, USB in; USB out once the light on the back stops flashing, the micro:bit back in), and the adult switches on. The box goes to 10, 20, 30, 40 and 50 cm from the sensor's front face; for each, the learner guesses, reads, and writes the difference, sensor minus ruler. Then the learner reads 30 cm three more times, and once with the box turned at an angle, and says which readings were steady. Last, the learner writes a correction card: My sensor reads __ cm more (or less) than the ruler, from __ to __ cm; a difference of 0 or −1 cm needs no correction.

    Starting blocks: The learner's session 3 blocks, set back to cm.

    Pins

    P1
    distance sensor Trig
    P2
    distance sensor Echo

    Evidence to collect

    A prediction for each distance, the learner's own short test table (Ruler (cm) | My guess | Sensor (cm) | Difference (cm)) for five distances, and the learner's spoken or written explanation of their correction and when it can be trusted.

    Test table columns: Ruler (cm) | My guess | Sensor (cm) | Difference (cm)

    Predict
    Before each distance, the learner guesses whether the difference will be the same as last time.
    Debug
    If one difference is far from the others, measure that distance again: one odd reading is not a pattern.
    Reflect
    How would you know if your correction stopped working?

    ⚠ Adult checks before power-on: Nothing metal touches the micro:bit, its gold pins or the board, and nothing metal lies under it. Before the adult switches on: the micro:bit is firmly in the board, display facing the Link header, its own battery pack and USB unplugged; both switches were off while anything was plugged in or moved. The distance sensor is an RCWL-1601, sold for 3 V or 5 V but never powered from 5 V here: it runs from the Link header's 3V pin, so its Echo signal is 3.3 V. Never a 5 V-only HC-SR04. Plastic toy vehicles only near the board; nothing metal on or under it. Rewire only when unpowered: the board and the holder are switched off before any wire, motor, servo or sensor is plugged in, moved or taken out.

    Works towards: Calibration

  5. Session 5 · 75 min

    Can my parking display help a driver stop in time?

    The prototype, a digital parking-distance display: the sensor at the back of a parking bay, and “plot bar graph” of the distance in cm up to 50: fewer rows light, counted from the bottom, as a toy car reverses closer. The display shows one thing at a time: the rows first, then the number with session 2's program. The learner compares both with the ruler, using the correction card.

    The adult says first: “Your display shows how near the car is. Check it against the ruler.”

    Learner card

    1. Reverse the car with a ruler.
    2. Guess the rows.
    3. Count rows from the bottom.
    4. Then read the number.
    5. Does the ruler agree?

    Key words (show each with a picture): parking · bar graph · compare

    Timing (15 of 75 min at the screen)

    1. 10 minAway from the screen: Set up the parking bay; mark 40, 30, 20, 10 and 5 cm; guess the rows.
    2. 10 minAt the screen: Build the bar graph; the simulator (all five rows), then download.
    3. 20 minAway from the screen: Reverse the car with a ruler to each mark; count the rows lit from the bottom.
    4. 5 minAt the screen: Session 2's number program; download.
    5. 15 minAway from the screen: The same five marks: read the number.
    6. 15 minAway from the screen: Apply the correction card; explain where the sensor and the ruler agreed.

    In the studio

    No studio lab or activity.

    Outside the studio: MakeCode editor and its micro:bit simulator (makecode.microbit.org)

    Hands-on

    In the simulator first, the learner builds “forever” holding “plot bar graph” of “ping trig P1 echo P2 unit …” (cm) up to 50; in the simulator all 5 rows light, because its made-up 86 is above 50. Then the learner downloads it (the board switched off, the micro:bit out of the board, USB in; USB out once the light on the back stops flashing, the micro:bit back in); the sensor stands at the back of a shoebox laid on its side as the parking bay, facing out, with the ruler's 0 at its front face, and the adult switches on. The learner reverses a plastic toy car into the bay, pushing it with a ruler, and stops at five marks (40, 30, 20, 10 and 5 cm); at each the learner guesses, then counts the rows lit from the bottom (a row counts if any of its lights is on). Then the learner downloads session 2's number program the same way and reads the number at the same five marks. Last, the learner applies the correction card and explains where the sensor and the ruler agreed.

    Starting blocks: The learner's own blocks from session 4, with “plot bar graph” in “forever”; then session 2's number program.

    Pins

    P1
    distance sensor Trig
    P2
    distance sensor Echo

    Evidence to collect

    The unit's evidence: the learner compares sensor and ruler readings: a prediction for each of five marks, the learner's own short test table (Ruler (cm) | My guess (rows) | Rows lit | Sensor (cm)), and the learner's spoken or written explanation of where the sensor and the ruler agreed, where they did not, and how the correction card helped.

    Test table columns: Ruler (cm) | My guess (rows) | Rows lit | Sensor (cm)

    Predict
    Before each mark, the learner guesses how many rows will light.
    Debug
    If the rows jump about, the car may be at an angle: straighten it and read again. A 0 still lights the bottom middle light, so it looks like 1 row: the number tells you which.
    Reflect
    Would you trust your display to park a real car? What would you test first?

    ⚠ Adult checks before power-on: Nothing metal touches the micro:bit, its gold pins or the board, and nothing metal lies under it. Before the adult switches on: the micro:bit is firmly in the board, display facing the Link header, its own battery pack and USB unplugged; both switches were off while anything was plugged in or moved. The distance sensor is an RCWL-1601, sold for 3 V or 5 V but never powered from 5 V here: it runs from the Link header's 3V pin, so its Echo signal is 3.3 V. Never a 5 V-only HC-SR04. Plastic toy vehicles only near the board; nothing metal on or under it. Rewire only when unpowered: the board and the holder are switched off before any wire, motor, servo or sensor is plugged in, moved or taken out.

    Works towards: Distance sensing, Calibration

Materials

  • Per pair: a BBC micro:bit and its USB cable (USB micro-B at the micro:bit end)
  • A computer with a web browser for MakeCode (makecode.microbit.org); no installs needed
  • Per pair: a Kitronik Compact All-In-One Robotics Board for BBC micro:bit (stock code 5693), its Link header fitted with a 2.54 mm pin header by the adult (soldering is adult-only)
  • Kept by the adult: 4 × AA alkaline cells (1.5 V each, 6 V nominal) in a holder with a screwed-shut cover and its own on/off switch, wired by the adult to the board's power terminal block; no rechargeable cells, Li-ion, LiPo, RC or coin-cell packs
  • Pencils and paper for the test tables
  • Per pair: a 3.3 V-safe RCWL-1601 ultrasonic distance sensor, never a 5 V-only HC-SR04, and four female-to-female jumper wires
  • A 30 cm ruler, masking tape, a small cardboard box, a shoebox for the parking bay and a plastic toy car
  • A soft jumper or cloth for the echo test, and a calculator for dividing by 58

⚠ Safety before any session

  • Batteries: only AA alkaline cells in the board's closed holder, and USB from a computer for downloads; no rechargeable cells, power banks, Li-ion, LiPo, RC packs or coin cells.
  • Cells: the adult fits four new alkaline cells of one type, the right way round, never mixes new and used cells, takes spent cells out and screws the cover shut.
  • The battery holder stays with the adult, beside the board on the adult's side; learners never handle the cells or the holder.
  • The power-off switch is the board's on/off switch: it cuts the battery to the board, the micro:bit and every motor and servo. Anyone may switch it off at any time; only the adult switches it on.
  • The distance sensor is an RCWL-1601, sold for 3 V or 5 V but never powered from 5 V here: it runs from the Link header's 3V pin, so its Echo signal is 3.3 V. Never a 5 V-only HC-SR04.
  • Only the parts the plan names connect to the micro:bit, through the board's Link header. Never connect a 5 V signal or supply to a micro:bit's pins or battery socket: it runs at 3.6 V at most.
  • Rewire only when unpowered: the board and the holder are switched off before any wire, motor, servo or sensor is plugged in, moved or taken out.
  • Plastic toy vehicles only near the board; nothing metal on or under it.
  • If the board, a motor, the holder or a wire gets warm: switch the board off, don't touch it, tell the adult.

Notes for the adult

  • Read each step aloud first: your words come before the learner's card. The card uses short sentences; show each key word with a picture.
  • These plans assume one adult for up to four pairs. Learners plug the USB cable into their own computer, gripping the plug, while the adult watches; only the adult handles cells and battery packs. With more pairs, add an adult or bring fewer pairs to the real board at once.
  • Kitronik labels the board Age 11+ and tags it Designed for_Engineers. These plans are adult-led for that reason: the adult builds, wires, powers and switches every rig and keeps the battery holder; the learner changes numbers in blocks, presses the micro:bit's buttons when the adult says, and watches from outside the safe zone or the gate's path.
  • Each session's timing keeps screen time to short bursts (15 minutes at most), with building, acting or testing away from the screen between them.
  • Before the first session on the real board, set up each computer and test a download: either pair each micro:bit once with WebUSB (then MakeCode's Download button sends the program straight to it), or download the .hex file and drag it onto the MICROBIT drive. The light on the back flashes while the program copies: unplug only after it stops.
  • To download, the board is switched off and the adult takes the micro:bit out of it (or the learner does, with the adult watching), holding it by its edges and pulling it straight out; the learner plugs in USB, downloads and unplugs USB once the light on the back stops flashing; the micro:bit goes back in the same way, straight and firmly, display facing the Link header, before the adult switches on. Every swap wears the edge connector a little: swap only to download or at a pair's turn, and never rock the micro:bit out.
  • Before the first session, add the extensions on each computer: in MakeCode's Extensions, search for Kitronik and pick the Kitronik robotics Board; for the distance sensor, search for sonar.
  • The MakeCode simulator prepares the work. Only the real board, seen working by the adult, counts as evidence: a simulator run is never physical success.
  • Learners already make their own test tables (R09-U3): give the columns, and the learner draws and fills in the table.
  • The studio's Arduino labs are written for ages 12 and up and are not used in this unit, not even its motor, servo or distance labs: they wire a 5 V Uno, never a micro:bit.
  • The pack is 6 V nominal (4 × 1.5 V), at the edge of all three ranges: the bottom of Kitronik's recommended 6.0–10.8 V for the board, and the top of the TT motor's 3–6 V and the servo's 4.8–6 V. Expect it to vary: new cells can read above 1.5 V each with nothing running (Energizer's handbook works an example with an open circuit voltage of 1.6 V), and the pack sags under load, because each fresh cell has 150 to 300 milliohms of internal resistance (Energizer E91). Kitronik's board page lists under Requires a Power Supply that links to its 3 × AA holder; these plans use 4 × AA instead, because 3 × AA is 4.5 V nominal, below the board's recommended 6.0 V and the servo's 4.8 V.
  • Before session 2, with the board switched off, the adult solders a pin header into the Link header (soldering is adult-only) and wires the sensor; the board's battery powers the micro:bit, and the micro:bit's own battery pack stays unplugged.
  • The sensor works best from about 10 to 250 cm and cannot see closer than about 2 to 3 cm; its beam spreads, so keep other objects out of the strip. Measure every distance from the sensor's front face.
  • The block keeps whole centimetres (the time ÷ 58 without its remainder), so a sensor that is exactly right still reads 0 or 1 cm under the ruler; only a bigger, steady difference needs a correction.
  • With “plot bar graph” up to 50, each of its 15 lights is one sixteenth of 50 cm (about 3.1 cm), three lights to a row from the bottom, so a new row lights about every 9.4 cm. At the five marks a perfect sensor gives 5 at 40 cm, 4 at 30 cm, 3 at 20 cm, 2 at 10 cm, 1 at 5 cm. Even a 0 lights the bottom middle light, so it looks like 1 row: read the number too.
  • No threshold or decision block is needed here: this unit is about distances, units and calibration. Deciding with a distance comes in R10-U4.
  • Readiness decides, not age: a learner who already reads a distance with its unit and checks a sensor against a ruler can move on to R10-U4 (with R10-U3).

Planned studio features

Not built yet. The unit runs without them.

  • A micro:bit-style blocks simulator in the studio, with a labelled simulated distance input (a stand-in, never a measurement).
  • Printable picture cards for each session's key words, and printable learner cards.
  • A printable parking-bay mat marked every 10 cm, and a correction-card template.

Sources

The facts this plan relies on, in each source's own words.