Sunteți pe pagina 1din 16

Arduino Radar Project using Processing, Ultras... https://www.electronicshub.org/arduino-radar-p...

ELECTRONICS HUB
P R OJ E C T S | T U TO R I A L S | C O U R S E S | K I T S

25 Male
No
Rs. 547

HOME PROJECTS MINI PROJECTS ARDUINO FREE CIRCUITS TUTORIALS SYMBOLS

DIY COURSES CONTACT US

YOU ARE HERE: HOME / ARDUINO / ARDUINO RADAR PROJECT

Arduino Radar Project


JUNE 14, 2018 BY RAVI — LEAVE A COMMENT

Table of Contents 
1. Introduction
2. Project Overview
3. Output Video
4. Circuit Diagram of Arduino Radar Project
5. Components Required
5.1. Hardware
5.2. Software
6. Circuit Design
7. Getting the Hardware Ready
8. A Reminder on Processing
9. Code
9.1. Arduino Code
9.2. Processing Code
10. Working

Introduction
In this project, I will show you how to design a simple Radar Application using Arduino and
Processing. This Arduino Radar Project is implemented with the help of Processing

1 of 16 28/10/19, 2:34 pm
Arduino Radar Project using Processing, Ultras... https://www.electronicshub.org/arduino-radar-p...

Application.  

25 Male
No

Rs. 547

Radar is a long-range object detection system that uses radio waves to establish certain
parameters of an object like its range, speed and position. Radar technology is used in
aircrafts, missiles, marine, weather predictions and automobiles.

Even though the title says Arduino Radar Project, technically the project is based on Sonar
technology as I will be using an Ultrasonic Sensor to determine the presence of any object in a
particular range.

Project Overview
The Arduino Radar Project is more of a visual project than it is a circuit implementation. Of
course, I will be using di�erent hardware like Arduino UNO, HC-SR04 Ultrasonic Sensor and a
Servo Motor but the main aspect is the visual representation in the Processing Application.

If you remember, I have already used the Processing Application in one of the earlier Arduino
Projects involving MPU-6050 Sensor. I suggest you to take a look at that project before
proceeding (you don’t have to actually implement the project but understand the way it is

2 of 16 28/10/19, 2:34 pm
Arduino Radar Project using Processing, Ultras... https://www.electronicshub.org/arduino-radar-p...

implemented).

Reference: GETTING STARTED WITH ARDUINO AND MPU6050

In the MPU-6050 Project, I have used Arduino to read the data from the MPU-6050 Sensor and
send it to Processing Application through the COM Port (Serial Communication).

Based on the information received, a sketch in Processing will change the orientation of the
model aircraft.

Taking the same concept here, I will collect the information from the Ultrasonic Sensor with
the help of Arduino and pass it to Processing where a simple Graphics application is
implemented to mimic a Radar Screen.

Output Video
Before proceeding with the circuit diagram and rest  of the things, take a look at the output in
the following video.

Arduino Radar Project

3 of 16 28/10/19, 2:34 pm
Arduino Radar Project using Processing, Ultras... https://www.electronicshub.org/arduino-radar-p...

Circuit Diagram of Arduino Radar Project


The circuit diagram of this Radar Project is very simple as it involves very little hardware.

Components Required
Hardware
Arduino UNO  [Buy Here]
HC-SR04 Ultrasonic Sensor  
TowerPro SG90 Servo Motor  
Mounting Bracket for Ultrasonic Sensor (optional)  
Connecting Wires  
Jumper Cables  
5V Power Supply  
USB Cable (for Arduino)  

Software
Arduino IDE
Processing Application

Circuit Design
If you look at the circuit diagram, the design of the circuit for this project is very simple. The
control pin of the servo is connected to Pin 11 of the Arduino while the TRIG and ECHO Pins of
the Ultrasonic Sensor are connected to Pins 9 & 10 of Arduino respectively.

4 of 16 28/10/19, 2:34 pm
Arduino Radar Project using Processing, Ultras... https://www.electronicshub.org/arduino-radar-p...

A separate 5V power supply (with common GND) is given to the Servo Motor and the
Ultrasonic Sensor.

Getting the Hardware Ready


After making the connections, there is one important step in the construction you need to
perform (not mandatory). Since the Ultrasonic Sensor must sweep an arc of 1800 (with the help
of the Servo), I have used a mounting bracket as shown in the image below to �x the
Ultrasonic Sensor.

After �xing the sensor, the mounting bracket is screwed to the servo motor as shown below.
As the bracket and the Ultrasonic Sensor adds weight to the servo, make sure to use a
double-sided-tape to �x the Servo �rmly to the surface.

This step is optional and you can make a simple structure with cardboard to hold the
Ultrasonic Sensor �rmly to the Servo.

5 of 16 28/10/19, 2:34 pm
Arduino Radar Project using Processing, Ultras... https://www.electronicshub.org/arduino-radar-p...

A Reminder on Processing
If you are new to processing, it is a visual arts based software for learning to code. To
download the application, visit the following link and choose your platform. Download
Processing.

After downloading the Zip �le (assuming the platform is 64-bit Windows), extract the contents
of the zip �le and you can �nd the processing application (.exe �le).

The next step is to download a special library called “Toxi” from this link. After downloading
the “toxiclibs-complete-0020” zip �le, extract the contents to the folder of same name and
move that folder to the Processing libraries directory (something like C:\Users
\Ravi\Documents\Processing\libraries).

Code
There are two codes for this project: one for the Arduino UNO and the other for the Processing.

Arduino Code
The code for Arduino UNO is given below.

1 #include <Servo.h>
2
3 const int trigPin = 9;
4 const int echoPin = 10;
5
6 long duration;
7 int distinCM;
8
9 Servo radarServo;
10
11 void setup()

6 of 16 28/10/19, 2:34 pm
Arduino Radar Project using Processing, Ultras... https://www.electronicshub.org/arduino-radar-p...

12 {
13 pinMode(trigPin, OUTPUT);
14 pinMode(echoPin, INPUT);
15 Serial.begin(9600);
16 radarServo.attach(11);
17 }
18 void loop()
19 {
20 for(int i=0;i<=180;i++)
21 {
22 radarServo.write(i);
23 delay(50);
24
25 digitalWrite(trigPin, LOW);
26 delayMicroseconds(2);
27 digitalWrite(trigPin, HIGH);
28 delayMicroseconds(10);
29 digitalWrite(trigPin, LOW);
30 duration = pulseIn(echoPin, HIGH);
31 distinCM = duration*0.034/2;
32
33 Serial.print(i);
34 Serial.print("*");
35 Serial.print(distinCM);
36 Serial.print("#");
37 }
38
39 for(int i=180;i>=0;i--)
40 {
41 radarServo.write(i);
42 delay(50);
43 digitalWrite(trigPin, LOW);
44 delayMicroseconds(2);
45 digitalWrite(trigPin, HIGH);
46 delayMicroseconds(10);
47 digitalWrite(trigPin, LOW);
48 duration = pulseIn(echoPin, HIGH);
49 distinCM = duration*0.034/2;
50
51 Serial.print(i);
52 Serial.print("*");
53 Serial.print(distinCM);
54 Serial.print("#");
55 }
56 }

Arduino_Radar_Arduino_Code.ino hosted with by GitHub view raw

Processing Code

7 of 16 28/10/19, 2:34 pm
Arduino Radar Project using Processing, Ultras... https://www.electronicshub.org/arduino-radar-p...

The code for Processing Application is given below.

1 import processing.serial.*;
2 import processing.opengl.*;
3 import toxi.geom.*;
4 import toxi.processing.*;
5
6 ToxiclibsSupport gfx;
7
8
9 Serial port;
10 String serialAngle;
11 String serialDistance;
12 String serialData;
13 float objectDistance;
14 int radarAngle, radarDistance;
15 int index=0;
16
17 void setup()
18 {
19 size (1280, 720);
20 gfx = new ToxiclibsSupport(this);
21 smooth();
22
23 //println(Serial.list());
24
25 //String portName = Serial.list()[0];
26 String portName = "COM4";
27 port = new Serial(this, portName, 9600);
28
29 //port = new Serial(this,"COM4", 9600);
30 port.bufferUntil('#');
31 }
32
33 void draw()
34 {
35 //fill(10,255,10);
36 noStroke();
37
38 fill(0,4);
39 rect(0, 0, 1280, 720);
40 fill(10,255,10);
41
42 //Radar Arcs and Lines
43 pushMatrix();
44
45 translate(640,666);
46 noFill();
47 strokeWeight(2);
48 stroke(10,255,10);

8 of 16 28/10/19, 2:34 pm
Arduino Radar Project using Processing, Ultras... https://www.electronicshub.org/arduino-radar-p...

49 arc(0,0,1200,1200,PI,TWO_PI);
50 arc(0,0,934,934,PI,TWO_PI);
51 arc(0,0,666,666,PI,TWO_PI);
52 arc(0,0,400,400,PI,TWO_PI);
53 strokeWeight(4);
54 line(-640,0,640,0);
55 line(0,0,-554,-320);
56 line(0,0,-320,-554);
57 line(0,0,0,-640);
58 line(0,0,320,-554);
59 line(0,0,554,-320);
60
61 popMatrix();
62
63 //Ultrasonic Lines
64 pushMatrix();
65
66 strokeWeight(5);
67 stroke(10,255,10);
68 translate(640,666);
69 line(0,0,640*cos(radians(radarAngle)),-640*sin(radians(radarAngle)));
70
71 popMatrix();
72
73 //Object Detection Lines
74 pushMatrix();
75
76 translate(640,666);
77 strokeWeight(5);
78 stroke(255,10,10); // red color
79 objectDistance = radarDistance*15;
80
81 if(radarDistance<40)
82 {
83 line(objectDistance*cos(radians(radarAngle)),-objectDistance*sin(radians(radarAngle)),
84 }
85
86 popMatrix();
87 }
88
89 void serialEvent (Serial port)
90 {
91 serialData = port.readStringUntil('#');
92 serialData = serialData.substring(0,serialData.length()-1);
93
94 index = serialData.indexOf("*");
95
96 serialAngle= serialData.substring(0, index);
97 serialDistance= serialData.substring(index+1, serialData.length());
98

9 of 16 28/10/19, 2:34 pm
Arduino Radar Project using Processing, Ultras... https://www.electronicshub.org/arduino-radar-p...

99 radarAngle = int(serialAngle);
100 radarDistance = int(serialDistance);
101 }
102

Arduino_Radar_Processing_Code.pde hosted with by GitHub view raw

Working
Initially, upload the code to Arduino after making the connections. You can observe the servo
sweeping from 00 to 1800 and again back to 00. Since the Ultrasonic Sensor is mounted over
the Servo, it will also participate in the sweeping action.

Now, open the processing application and paste the above given sketch. In the Processing
Sketch, make necessary changes in the COM Port selection and replace it with the COM Port
number to which your Arduino is connected to.

If you note the Processing Sketch, I have used the output display size as 1280×720 (assuming
almost all computers now-a-days have a minimum resolution of 1366×768) and made
calculation with respect to this resolution.

In the future, I will upload a new Processing sketch where you can enter the desired resolution
(like 1920×1080) and all the calculations will be automatically adjusted to this resolution.

Now, run the sketch in the Processing and if everything goes well, a new Processing window
opens up like the one shown below.  

A Graphical representation of the data from the Ultrasonic Sensor is represented in a Radar
type display. If the Ultrasonic Sensor detects any object within its range, the same will be

10 of 16 28/10/19, 2:34 pm
Arduino Radar Project using Processing, Ultras... https://www.electronicshub.org/arduino-radar-p...

displayed graphically on the screen.  

frompdftodoc.com

FILED UNDER: ARDUINO, DIY PROJECTS

11 of 16 28/10/19, 2:34 pm
Arduino Radar Project using Processing, Ultras... https://www.electronicshub.org/arduino-radar-p...

Leave a Reply
Your email address will not be published. Required �elds are marked *

Comment

Name *

Email *

Website

POST COMMENT

Search this website

PCB Assembly Services

12 of 16 28/10/19, 2:34 pm
Arduino Radar Project using Processing, Ultras... https://www.electronicshub.org/arduino-radar-p...

SPONSORED SEARCH

Radar System Using Ar

ultrasonic radar project

pcb circuit

PROJECTS BY CATEGORY

Arduino Projects (200+)


Electronics Projects (250+)
Mini Project Circuits (160+)
Mini Project Ideas (150+)
ECE Projects (150+)
EEE Projects (150+)
8051 Projects (110+)

13 of 16 28/10/19, 2:34 pm
Arduino Radar Project using Processing, Ultras... https://www.electronicshub.org/arduino-radar-p...

Raspberry Pi Projects (101+)


Electrical Project Ideas (100+)
Embedded Projects (100+)
Latest Electronics Ideas (100+)
Microcontroller Mini Projects (100+)
Robotics Projects (100+)
VLSI Projects (100+)
Solar Projects (100+)
IOT Projects (100+)

Communication Projects (70+)


LED Projects (70+)
Power Electronics Projects (60+)
RFID Projects (60+)
Home Automation Projects (50+)
Matlab Projects (50+)
EIE Projects (50+)
Wireless Projects (50+)
LabView Projects (45+)
Zigbee Projects (45+)
GSM Projects (40+)
555 Timer Circuits (40+)
Sensor Projects (40+)
ARM Projects (60+)
DTMF Projects (30+)
PIC Projects (30+)
Electrical Mini Projects (25)
ESP8266 Projects (15)

KITS

Best Drone Kits [12]


3D Printer Kits [12]
Best Robot Vacuum Clears [14]
Best Waveform Generators [12]
RGB LED Strip Light Kits [20]
Best LED Christmas Light Kits [13]

14 of 16 28/10/19, 2:34 pm
Arduino Radar Project using Processing, Ultras... https://www.electronicshub.org/arduino-radar-p...

SUBSCRIBE FOR UPDATES

Enter your email address:

SUBSCRIBE

GENERAL PROJECTS PROJECTS TUTORIALS

Tutorials Electrical Mini projects Capacitors


Symbols Electronics Microcontroller Resistors
Courses Embedded Arduino Filters
Calculator Power Solar Diodes

15 of 16 28/10/19, 2:34 pm
Arduino Radar Project using Processing, Ultras... https://www.electronicshub.org/arduino-radar-p...

Contact Robotics Free circuits Transistors


HomeZene ARM Home Automation
TUTORIALS
Best Arduino Kits IOT Seminar Topics

Electronics Ampli�ers

Questions IO Devices
Thyristors
DC Circuits
Number System
TS EAMCET 2019

FOLLOW US

Instagram
Youtube
Facebook
Google Plus

Twitter

[footer_backtotop]
Copyright © 2019 Electronicshub.org

16 of 16 28/10/19, 2:34 pm

S-ar putea să vă placă și