Source: https://mokxi.com/teachers/plans/distance-and-presence
Updated: 2026-11-19

Lesson plan

# Distance and presence sensing lesson plan

How far, and is anyone there: ultrasonic timing, laser time of flight, Sharp IR curves, PIR and radar motion, and break beams, then a museum visitor counter that tells in from out and measures every visitor.

3 chapters, 7 lessons, about 6 hours, on the Arduino Uno R3. Every lesson runs in the browser, with nothing to install.

Start a class from this course

The unit

## Objectives and materials

### By the end, students can

- Sound, laser light and infrared triangles.
- PIR heat, microwave radar and break beams.
- A museum visitor counter.

### Materials for the whole unit

- Arduino Uno R3
- Character LCD with I2C backpack
- Full-size breadboard
- Half breadboard
- IR distance sensor, Sharp GP2Y0A21
- Laser distance, VL53L1X
- LED x 2
- Microwave motion sensor
- Motion sensor
- Photo interrupter, slot x 2
- Resistor x 2
- Ultrasonic ranger
- VL53L0X time-of-flight sensor

Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.

Chapter 1. About 2 h 35 min

## How far

Sound, laser light and infrared triangles.

Lesson | Time | What students do

Ultrasonic timing An HC-SR04 read by hand with pulseIn(): a chirp, an echo timed in microseconds, the speed of sound, and why a cold day reads long. | 55 min

- Run it: a chirp and an echo
- Microseconds to millimeters
- No echo at all
- The stop line
- A cold day
- Correct for the cold
- Where ultrasonic fits

Time of flight A VL53L0X laser ranger on I2C: timing light instead of sound, millimeters with no math, the 8190 that means nothing came back, and a shelf detector. | 50 min

- Run it: a laser ruler
- Move the target
- Out of range: 8190
- Something on the shelf
- A deeper shelf
- Sound or light?

IR distance curves A Sharp GP2Y0A21 read raw: a voltage that falls with distance along a curve, a power-law fit, the flat far end, and the fold-back that makes a close hand read far. | 50 min

- Run it: a voltage, not a distance
- A curve
- The flat far end
- Too close reads far
- Trust less
- Where a Sharp fits

### Materials

- Arduino Uno R3
- Full-size breadboard
- Half breadboard
- IR distance sensor, Sharp GP2Y0A21
- LED
- Resistor
- Ultrasonic ranger
- VL53L0X time-of-flight sensor

### Check for understanding

Each student finishes "IR distance curves" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Where a Sharp fits".

Chapter 2. About 2 h 25 min

## Is anyone there

PIR heat, microwave radar and break beams.

Lesson | Time | What students do

PIR behavior What a PIR’s OUT pin really does, timed: the hold time, the blind time after each pulse, repeat and single trigger, and a porch light on its own timer. | 55 min

- Run it: something moves
- The hold time
- Blind after each pulse
- Repeat and single trigger
- The porch light
- A longer porch light
- Using PIRs well

Microwave radar An RCWL-0516 Doppler radar: no blind time, sight through walls, and a room that counts as occupied only after two blips in ten seconds. | 50 min

- Run it: a blip
- Hold, and no blind time
- Empty again
- Why confirm?
- Trust one blip
- PIR or radar?

Break beams A slotted photo interrupter on an interrupt: things passing counted and timed, short flickers told apart, and a spinning disc read in RPM. | 40 min

- Run it: break the beam
- Timed to the millisecond
- A spinning disc
- A different disc
- Beams in the world

### Materials

- Arduino Uno R3
- Half breadboard
- LED x 2
- Microwave motion sensor
- Motion sensor
- Photo interrupter, slot
- Resistor x 2

### Check for understanding

Each student finishes "Break beams" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Beams in the world".

Chapter 3. About 55 min

## Boss

A museum visitor counter.

Lesson | Time | What students do

Boss: a museum visitor counter Two break beams tell in from out, a VL53L1X in the ceiling measures each visitor, and an LCD by the door shows who is inside and when the room is full. | 55 min

- Run it: the doorway
- Walk in
- How tall?
- Turned back
- Walk out
- Full
- A smaller room

### Materials

- Arduino Uno R3
- Character LCD with I2C backpack
- Laser distance, VL53L1X
- Photo interrupter, slot x 2

### Check for understanding

Each student finishes "Boss: a museum visitor counter" on their own, without opening the hints. The simulator checks 7 of its 7 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "A smaller room".

Your class

## Teach this unit as a class

Start a class from this course and its 7 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.

The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.

Start a class from this course See the demo class

More units

## Other lesson plans

Electronics basics 20 lessons, about 10 h. Embedded on the Arduino Uno 16 lessons, about 12 h. Embedded on the ESP32-C3 13 lessons, about 11 h. Embedded on the Raspberry Pi Pico 7 lessons, about 6 h. Build your own fight stick 5 lessons, about 4 h. Embedded on the STM32F411 6 lessons, about 6 h. C++ on a board 13 lessons, about 10 h. Digital logic and memory 4 lessons, about 4 h. Interactive devices on the Uno 9 lessons, about 8 h. From gates to a computer 23 lessons, about 16 h. Build a claw machine 8 lessons, about 6 h. Every unit All the courses as ready-made units, on the teachers page.
