A working radar scope built from an Arduino, an HC-SR04 ultrasonic sensor, and a servo. The sensor sweeps 180 degrees back and forth while a Processing sketch renders a classic green phosphor radar display in real time: fading sweep trail, range rings every 10 cm, and anything inside 40 cm painted red at its exact angle and distance.
What the display renders: sweep trail, range rings, and a red return at 27 cm (frame reproduced from the display's drawing code with simulated serial data)
servo sweeps 15°-165° serial "angle,distance." Processing 4
HC-SR04 pings at each step → 9600 baud, '.' terminated → radar scope UI
The Arduino steps the servo one degree at a time, fires the HC-SR04 at each step, and streams angle,distance. packets over serial. The Processing sketch buffers on the . terminator, splits on the comma, and redraws:
- Sweep line at the live servo angle, with a translucent black overlay each frame so old sweeps fade out like a real scope
- Red return line from the measured distance out to the edge of the scan area when an object is inside 40 cm
- Range rings marked at 10 / 20 / 30 / 40 cm, plus live angle and distance readouts in the corners
The parser is defensive on purpose: null reads, empty lines, and malformed packets are dropped instead of crashing the display mid-demo.
| Part | Pin |
|---|---|
| HC-SR04 TRIG | D10 |
| HC-SR04 ECHO | D11 |
| Servo signal | D12 |
| Both | 5V + GND |
- Flash
arduino/radar_arduino/radar_arduino.inoto the board. - Open
processing/radar_display/radar_display.pdein Processing 4. - Set the COM port in
setup()(currentlyCOM16; check Arduino IDE > Tools > Port) and make sure the Arduino Serial Monitor is closed, since only one program can hold the port. - Run. Wave a hand inside 40 cm of the sensor.
Note: the Arduino sketch is the standard sweep implementation written to match the display's exact serial protocol. If you have the club's original board sketch, drop it in; angle,distance. at 9600 baud is the only contract.
Built for a Compsci & Robotics Club session at Hodan Nalayeh SS.