Source: https://mokxi.com/learn/path/distance-and-presence
Updated: 2026-11-20

All paths

# Distance and presence sensing

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.

Arduino Uno R3 Free 7 lessons 6 h 3 chapters 2,011 XP Robotics · Intermediate +150 XP

0 of 7 done

Start the course free Ultrasonic timing Lesson plan for teachers

What you will build

## 2 projects, built step by step

7 lessons in 3 chapters, about 6 hours on a simulated Arduino Uno R3. Free, in your browser, every step checked by the simulator.

Chapter 1 project

### 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.
Open it in the simulator

Chapter 2 project

### 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.
Open it in the simulator

The map

## Chapter by chapter

Each lesson opens when the one before it is done, and each chapter ends in a project.

Chapter 1

## How far

Sound, laser light and infrared triangles.

Open 249 XP

### 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.

0 of 7 steps

Start What is in it

Locked 218 XP

### 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.

0 of 6 steps

Project Locked 436 XP

### 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.

0 of 6 steps

4 questions, graded as you go.

Chapter 2

## Is anyone there

PIR heat, microwave radar and break beams.

Locked 249 XP

### 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.

0 of 7 steps

Locked 218 XP

### 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.

0 of 6 steps

Project Locked 374 XP

### 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.

0 of 5 steps

4 questions, graded as you go.

Chapter 3

## Boss

A museum visitor counter.

Locked 267 XP

### 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.

0 of 7 steps

3 questions, graded as you go.

Syllabus

## Every lesson in the course

All 7 lessons, in order, each with what it covers. Any of them opens in the editor right away.

Chapter 1

### How far

- 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.
- 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.
- 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.

Chapter 2

### Is anyone there

- 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.
- 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.
- 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.

Chapter 3

### Boss

- 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.

Kits

## Build it on your bench too

Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.

Have a kit already?

### Find your kit

Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.
See every kit

Questions

## About Distance and presence sensing

Is Distance and presence sensing free?

Yes. All 7 lessons of Distance and presence sensing are free and run in your browser, with nothing to install and no parts to buy before you start.

Do I need a real Arduino Uno R3?

No. Every lesson runs on a simulated Arduino Uno R3 with its parts on the canvas, and the simulator checks each step as you go. When you want to build it for real, the same wiring and code work on a real board.

How long does Distance and presence sensing take?

About 6 hours: 7 lessons in 3 chapters, each one a few short steps. Your progress is kept, so you can stop after any lesson and pick up where you left off.

What will I build?

Each chapter ends in a project that puts it together: IR distance curves and Break beams.

Where do I start?

With "Ultrasonic timing", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.
