Virtual Displays: The Arduino Radar Mapping
A single HC-SR04 sonar sensor can only measure distance directly in front of it. The Arduino Radar project mimics a submarine or air-traffic control tower. By physically sweeping the sensor across the room and tying the data into a Java application, you construct a complete 2D map of your surroundings.

Servo Kinematics & Data Transmission
The hardware mechanism dictates the software timing.
- An HC-SR04 Ultrasonic Sensor is hot-glued directly on top of the horn of an SG90 Micro Servo.
- The Sweep Loop: The Arduino runs a
for(pos = 0; pos <= 180; pos++)loop. For every single degree, the servo stops briefly, the sonar fires a ping, and measures the distance (e.g., at degree 45, an object is 10cm away). - The Communication Payload: The Arduino compresses these two variables into a comma-separated serial string and blasts it over USB:
45,10.0\n.
Translating Reality to a Digital Display (Processing)
The Serial Monitor strings are useless to a human operator. You must use the Processing IDE on your computer.
- The Java script opens the COM port and swallows the
45,10.0payload. - It uses incredibly complex Polar-to-Cartesian trigonometric math (
cos(),sin()) to calculate exactly where that object is on the computer screen. - It draws a sweeping green "Radar Line" that pivots 180 degrees.
- When an object is detected, it draws an intense Red blip precisely where the object is located in the real room! The visual updates flawlessly in real-time as the physical radar sweeps back and forth!
System Elements
- Arduino Uno/Nano: The physical actuator and data aggregator.
- SG90 Servo Motor and HC-SR04 Sensor.
- A heavily weighted 3D-printed chassis (The fast servo motion will make the base chassis flip over if it is not secured down!).
- Processing 3 or 4 IDE running the graphic display code on a PC/Mac.