. Arduino Radar | Arduino Project ~ SmartElectronicsDIY

Arduino Radar | Arduino Project

 

The Arduino Radar  is an interesting and educational electronics project that simulates the working principle of a real radar system using Arduino. This project detects objects in a specific area and displays their distance and angle, making it ideal for beginners and engineering students.

The project is built using an Arduino UNO, an ultrasonic sensor (HC-SR04), and a servo motor. The ultrasonic sensor is mounted on the servo motor, which rotates from 0° to 180°. As the servo rotates, the ultrasonic sensor continuously sends sound waves and receives the reflected signals from nearby objects. The Arduino calculates the distance based on the time taken for the echo to return.

The collected data is sent to a computer via serial communication and visualized using the Processing IDE, where it appears like a radar screen showing detected objects in real time. This makes the project both interactive and visually appealing.

Arduino Radar Kit projects are widely used for learning sensor interfacing, servo control, serial communication, and basic object detection concepts. It can be further enhanced by adding wireless modules, IoT connectivity, or multiple sensors.

Overall, this project is a great way to understand how radar-like systems work using simple and affordable components.


 Arduino Radar Project

🔧 Components Required

No.ComponentQuantity
1Arduino UNO1
2Ultrasonic Sensor (HC-SR04)1
3Servo Motor (SG90)1
4Breadboard1
5Jumper Wires (Male–Male)As required
6USB Cable (Arduino)1
7Computer / Laptop (Processing IDE)1

🔌 Pin Connections

HC-SR04 Ultrasonic Sensor

  • VCC → 5V (Arduino)

  • GND → GND

  • Trig → D9

  • Echo → D10

Servo Motor

  • Red → 5V

  • Brown/Black → GND

  • Yellow/Orange → D6


💻 Arduino Code (Upload to Arduino UNO)

#include <Servo.h> Servo radarServo; const int trigPin = 9; const int echoPin = 10; long duration; int distance; void setup() { pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); Serial.begin(9600); radarServo.attach(6); } void loop() { for (int angle = 15; angle <= 165; angle++) { radarServo.write(angle); delay(20); distance = calculateDistance(); Serial.print(angle); Serial.print(","); Serial.print(distance); Serial.print("."); } for (int angle = 165; angle >= 15; angle--) { radarServo.write(angle); delay(20); distance = calculateDistance(); Serial.print(angle); Serial.print(","); Serial.print(distance); Serial.print("."); } } int calculateDistance() { digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); return duration * 0.034 / 2; }

🖥️ Processing Code (Radar Display on PC)

import processing.serial.*; Serial myPort; String data = ""; int angle = 0; int distance = 0; void setup() { size(800, 600); smooth(); myPort = new Serial(this, Serial.list()[0], 9600); myPort.bufferUntil('.'); } void draw() { background(0); translate(width / 2, height); stroke(0, 255, 0); noFill(); arc(0, 0, 600, 600, PI, TWO_PI); arc(0, 0, 400, 400, PI, TWO_PI); arc(0, 0, 200, 200, PI, TWO_PI); float radarAngle = radians(angle); line(0, 0, 300 * cos(radarAngle), -300 * sin(radarAngle)); if (distance < 200) { stroke(255, 0, 0); line(0, 0, distance * 3 * cos(radarAngle), -distance * 3 * sin(radarAngle)); } } void serialEvent(Serial myPort) { data = myPort.readStringUntil('.'); if (data != null) { data = trim(data); int[] values = int(split(data, ',')); angle = values[0]; distance = values[1]; } }

⚙️ Working Principle (Short)

  • Servo rotates ultrasonic sensor from 15° to 165°

  • Sensor detects object distance

  • Arduino sends angle + distance via serial

  • Processing displays real-time radar visualization

0 comments:

Post a Comment