Ultrasonic — Pitch by Distance
Closer = higher pitch
Ultrasonic
Buzzer
map
Sound
What you will learn
- How to use map() to convert a sensor range to an output range
- How to invert a relationship (close = high, far = low) with arithmetic
- How to use the constrain() function to keep values in safe bounds
What you will need
| Component |
|---|
| 1× Arduino Uno |
| 1× HC-SR04 |
| 1× buzzer |
| Breadboard |
| 4× jumper wires |
Step by step
Take it further
- Add an LED that changes brightness with distance (closer = brighter).
- Use two ultrasonic sensors to make a stereo theremin (left + right hand).
- Record the last 10 distances in an array — show "min" and "max" distance in the Serial Monitor.
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.
Related projects
Ultrasonic — Reverse Parking SensorBeep faster as you get closer
Arduino Nano — Parking Sensor4 distance zones — 1 slow low beep far, 2 fast high-pitch beeps close (like a real car reversing buzzer)
Police SirenAlternating red + blue LEDs with a wailing 600–1500 Hz buzzer
DHT11 — Temperature AlarmToo hot, too cold, or just right
PIR — Intruder AlarmMotion + armed switch = loud alarm. Disarm first.
PIR — Smart Doorbell / Welcome LightA guest walks up to the door — chime + welcome LED
Where this project sits
It is also part of these lists, which is how a class usually finds it.
Arduino ultrasonic distance sensor projects10 projects in this list
Arduino buzzer and tone projects19 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.