A real-time object detection and visualization system using Arduino, ultrasonic sensors, and Processing for radar-like display.
This project creates a radar-like system that detects objects within a 180-degree range using an ultrasonic sensor mounted on a servo motor. The Arduino controls the hardware and sends distance data to a Processing sketch that visualizes the detected objects in real-time on a radar display.
- 180-degree scanning range with servo motor control
- Real-time object detection up to 40cm distance
- Visual radar display using Processing
- Distance and angle tracking for detected objects
- Smooth animation with color-coded detection zones
- Serial communication between Arduino and Processing
Hardware:
- Arduino Uno/Nano
- HC-SR04 Ultrasonic Sensor
- Servo Motor
- Jumper Wires
Software:
- Arduino IDE
- Processing IDE
- C++ (Arduino)
- Processing (Java-based)
Connections:
Ultrasonic Sensor (HC-SR04):
- VCC → 5V
- GND → GND
- Trig → Pin 11
- Echo → Pin 12
Servo Motor:
- VCC → 5V
- GND → GND
- Signal → Pin 13
- Arduino IDE installed (Download here)
- Processing IDE installed (Download here)
- Clone this repository:
git clone https://github.com/TataNikhil5687/Radar-Detection-System.git
cd Radar-Detection-System-
Open
radar.inoin Arduino IDE -
Connect your Arduino board via USB
-
Select correct board and port:
- Tools → Board → Arduino Uno (or your board)
- Tools → Port → Select your COM port
-
Upload the code to Arduino
-
Open
radar.pdein Processing IDE -
IMPORTANT: Update the COM port in the code (line 13):
myPort = new Serial(this,"COM8", 9600); // Change COM8 to your portTo find your port:
- Windows: Check Device Manager → Ports (COM & LPT)
- Mac/Linux: Usually
/dev/ttyUSB0or/dev/ttyACM0
-
Run the Processing sketch
-
The radar display should appear and start scanning!
-
Arduino Controller:
- Rotates servo from 15° to 165° and back
- Triggers ultrasonic sensor at each angle
- Calculates distance using sound wave time-of-flight
- Sends angle and distance data via Serial:
angle,distance.
-
Processing Visualizer:
- Reads serial data from Arduino
- Parses angle and distance values
- Draws radar arcs and scanning line
- Highlights detected objects in red
- Displays distance and angle information
-
Detection Algorithm:
Distance = (Duration × Speed of Sound) / 2
Duration = Time for echo to return
Speed of Sound = 0.034 cm/μs
- Detection Range: 2cm - 40cm (optimal)
- Scanning Angle: 180° (15° to 165°)
- Angular Resolution: 1° per step
- Update Rate: ~25ms per angle step
- Communication: Serial @ 9600 baud
Issue: Radar display not showing objects
- Check all wire connections
- Verify correct COM port in Processing code
- Ensure Arduino is powered and code uploaded
Issue: Servo not moving smoothly
- Check servo power supply (should be 5V)
- Verify servo is connected to Pin 13
- Try reducing scanning speed (increase delay)
Issue: Inaccurate distance readings
- Clean ultrasonic sensor
- Avoid reflective or angled surfaces
- Ensure sensor is mounted firmly
- Increase detection range with better sensors
- Add sound alerts for close objects
- Implement object tracking and memory
- Add multiple sensor support for 360° scanning
- Create mobile app interface
- Add data logging and analysis features
Through this project, I gained hands-on experience with:
- Arduino programming and hardware interfacing
- Servo motor control and calibration
- Ultrasonic sensor physics and signal processing
- Serial communication protocols
- Real-time data visualization
- Processing framework and graphics programming
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
This project is licensed under the MIT License - see the LICENSE file for details.
Tata Nikhil Dharma Sai
- Email: tata.nikhildharmasai@gmail.com
- LinkedIn: linkedin.com/in/tatanikhil20
- GitHub: @TataNikhil5687
⭐ If you found this project interesting, please give it a star!
Project Link: https://github.com/TataNikhil5687/Radar-Detection-System