All projects
2026ArduinoSensorsControls

Sonar Scanner

A servo-mounted ultrasonic sensor sweeps 180 degrees and drives real-time RGB LED and buzzer feedback based on live distance readings.

Arduino MegaArduino IDEHC-SR04Servo Motor
Sonar Scanner

Role

Solo build, circuit design, and firmware

Goal

Build a sonar scanner that sweeps an ultrasonic sensor across a 180 degree range on a servo motor and gives real-time proximity feedback through a tiered RGB LED and buzzer response.

Challenge

The biggest challenge was keeping the ultrasonic distance reading synchronized with the servo's continuous sweep, the trigger and echo pulse cycle has to complete within each 10ms step of the servo's motion so the LED color and buzzer tone reflect the distance at the angle the sensor is actually pointed at, not a stale reading from a previous position.

Solution

The system was built on an Arduino Mega, sweeping a servo motor from 0 to 180 degrees and back in a continuous loop, with an HC-SR04 ultrasonic sensor firing a trigger and echo cycle at every single degree step and converting the pulse duration to distance using a 0.017 conversion factor. Distance feedback is split into three tiers, past 40cm the RGB LED shows green with the buzzer silent, between 10 and 40cm it shows yellow with a low 100Hz tone, and under 10cm it shows red with a sharper 500Hz tone. All components share a common 5V line and ground.

Results

  • Continuous 0 to 180 degree servo sweep with an ultrasonic distance read synchronized to every single degree step.
  • Three-tier RGB LED and buzzer feedback (green/silent past 40cm, yellow/100Hz between 10-40cm, red/500Hz under 10cm), each LED leg protected by a 220 ohm resistor.
  • Strengthened experience with sensor timing, multi-output conditional logic, and integrating actuation with real-time feedback on a single microcontroller loop.

Video

Sonar Scanner detail 2
Sonar Scanner detail 3