T ThinkEdge Learn

Arduino — Ultrasonic Distance on Serial

Read distance with HC-SR04 and print the cm on Serial Monitor

Arduino Ultrasonic HC-SR04 Serial pulseIn
Arduino ultrasonic distance sensor project · Tier 3 · Combined Projects · Advanced · 35 min · Arduino Uno

What you will learn

What you will need

Component
1× Arduino Uno R3
1× HC-SR04 ultrasonic sensor
3× 7-segment LED screens (hundreds / tens / ones)
1× breadboard
10× jumper wires

Step by step

Take it further

Practise it before you build it

Wire this circuit in the ThinkEdge Learn simulator first. The simulator runs a real Arduino sketch against a modified-nodal-analysis solver, so the LED on screen actually lights when the current is right — no hardware, no burnt components, and a class can try it in a browser.

Open the interactive lab See plans for your class

Related projects

Arduino Mega — Multi-Sensor Data HubRead 3 sensors at once and stream them to the Serial Monitor Arduino — Ultrasonic Radar ScannerA servo sweeps the ultrasonic sensor to scan the room Arduino Nano — Parking Sensor4 distance zones — 1 slow low beep far, 2 fast high-pitch beeps close (like a real car reversing buzzer) Ultrasonic — Reverse Parking SensorBeep faster as you get closer Ultrasonic — Pitch by DistanceCloser = higher pitch Ultrasonic — Object CounterCount things as they pass — like a door sensor or factory line

Guides that use this project

5 guides on the site build this project as part of a longer explanation. The guide says why the circuit works; this page says how to wire it.

Cleaning Robots: Bumpers, Cliff Sensors and the BrushHow a robot vacuum finds its way around a room, why cliff sensors matter more than the brush motor, and which Arduino projects teach each part of the loop. Window Cleaning Robots: How They Stick to GlassHow a window cleaning robot grips glass with a vacuum fan, why the squeegee matters as much as the suction, and how to build the winch logic. Raspberry Pi 5: What Changed Inside and How to Teach With ItThe Raspberry Pi 5 has a faster CPU, a new RP1 I/O chip and a 5 V power supply. What changed, what it costs, and how to use it in a classroom. Home Energy MonitoringHow to monitor energy use in a home or classroom: clamp meters, energy monitoring modules, the difference between watts and watt-hours, and what the data shows. Arduino Cloud EditorWhat the Arduino Cloud Editor is, what it does that the desktop IDE does not, and the honest limits you hit when a class runs entirely in a browser.

Where this project sits

It is also part of these lists, which is how a class usually finds it.

Arduino LED projects for beginners36 projects in this list Arduino ultrasonic distance sensor projects10 projects in this list

Try the full simulator with your class

103 guided circuit projects, 21 lessons and an in-browser Arduino simulator. The first 15 projects are free, no account needed. One licence covers a whole school.