← All Projects

Arduino Radar System with Processing Visualization

313 viewsFebruary 15, 2026
ArduinoServoHC-SR04ProcessingRadarVisualization

Build a mini radar system using an Arduino, a servo motor, and an HC-SR04 ultrasonic sensor. The servo sweeps 180° while the sensor scans for objects. Data is sent to a Processing sketch that renders a real-time radar display on your computer.

Components & Supplies

×1Arduino Uno R3
×1HC-SR04 Ultrasonic Sensor
×1SG90 Servo Motor
×1Breadboard
×6Jumper Wires (M-M)

Circuit Connections

ComponentPinPinComponent
ArduinoD9TRIGHC-SR04
ArduinoD10ECHOHC-SR04
Arduino5VVCCHC-SR04
ArduinoGNDGNDHC-SR04
ArduinoD6SignalServo
Arduino5VVCCServo
ArduinoGNDGNDServo

Overview

This project pairs Arduino hardware with a Processing (Java) desktop app to create a real-time radar display. The HC-SR04 sensor is mounted on a servo that sweeps from 0° to 180° and back. At each angle, the measured distance is sent over serial to the Processing sketch, which draws the familiar radar sweep animation.

Applications include room mapping, object detection demonstrations, and robotics obstacle awareness.

Setup

Setup requirements:

  • Install the Arduino IDE and upload the Arduino sketch.
  • Install Processing 4 from processing.org.
  • Mount the HC-SR04 on top of the servo horn so it rotates with the servo.
  • Connect Arduino to your computer via USB — the Processing sketch reads from the same serial port.
arduinoArduino Radar Sketch
#include <Servo.h>

Servo radarServo;
const int trigPin = 9;
const int echoPin = 10;

void setup() {
  Serial.begin(9600);
  radarServo.attach(6);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
}

float getDistance() {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  long duration = pulseIn(echoPin, HIGH);
  return (duration * 0.0343) / 2.0;
}

void loop() {
  // Sweep 0 to 180
  for (int angle = 0; angle <= 180; angle++) {
    radarServo.write(angle);
    delay(30);
    float dist = getDistance();
    Serial.print(angle);
    Serial.print(",");
    Serial.print(dist);
    Serial.println(".");
  }
  // Sweep 180 to 0
  for (int angle = 180; angle >= 0; angle--) {
    radarServo.write(angle);
    delay(30);
    float dist = getDistance();
    Serial.print(angle);
    Serial.print(",");
    Serial.print(dist);
    Serial.println(".");
  }
}