You are on page 1of 20

DIY GROUP

PROJECT
TEAM-22
Team Members

HP AL SK HS
Himanshu Panwar Anurag Lakra Shagun Katariya Harsh Saini
20GG20023 20EC30004 20HS20050 20CH30009

2
Topic : RADAR using an ultrasonic sensor

Our project is a simple


RADAR which uses an
ultrasonic sensor to detect an
object in front of it and
display them on a computer
screen.

3
Materials required

Breadboard Arduino
Uno

Servo motor
ultrasonic

4
sensor
TINKERCAD DIAGRAM

5
BIG CONCEPT
The Arduino sends a HIGH pulse width on the TRIGGER pin of the sensor to
regenerate a series of ultrasonic waves that propagate through the air until it
touches an obstacle and returns in the opposite direction towards the sensor pin
ECHO. The sensor detects the width of the pulse to calculate the distance of the
object.

6
Continued …

The signal on pin ECHO of the sensor remains at the HIGH position
during transmission, thereby measuring the duration of the round trip
of ultrasonic and thus determine the distance, then the output is
displayed on the computer screen using Processing software.

Meanwhile, the servo motor slowly rotates back and forth between 0°
and 180°.

7
VIDEO DEMONSTRATION

8
Roadmap
In week 1, we gathered all In week 2, we started
the information related to working on the coding part
our project. of our project.

1 2

3 4

In week 3, we got all the In the last week, we made some changes in
components and started the Processing coding and prepared the
assembling the model. video demonstration.

9
Arduino code
#include <Servo.h>
int trig = 9, echo = 10, servopin = 11;
int time;
float cm;
int i;
Servo servo;

void setup() {
// put your setup code here, to run once:
// selecting pinmode
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
Serial.begin(9600);
servo.attach(servopin);
}

void loop() {
// put your main code here, to run repeatedly:

for(i = 0;i<=180;i++){

servo.write(i);
cm = TimeToDistanceCM();

10
Continued…

printToSerial();
delay(100);
}

for(i=180;i>=0;i--){

servo.write(i);
cm = TimeToDistanceCM();
printToSerial();
delay(100);
}

int getUltraSonicTime()
{

digitalWrite(trig, LOW); // clearing the trigger

delayMicroseconds(2);

digitalWrite(trig , HIGH); // genrating sound pulses

11
Continued…
delayMicroseconds(10);

digitalWrite(trig, LOW);

return pulseIn(echo , HIGH);

float TimeToDistanceCM()
{
time = getUltraSonicTime();

return (time/2) * 0.0343260;


}

void printToSerial()
{
Serial.print(i);
Serial.print("*");
Serial.print(cm);
Serial.print("#");
}

12
Processing code

import processing.serial.*; //library to access serial output from arduino//


import processing.opengl.*; //it will give access to utilize the gpu for fast processing//
import toxi.geom.*;// this toxi library has fuctions for calculations
import toxi.processing.*;

Serial myPort;
String serialAngle;
String serialDistance;
String serialData;
float ObjectDistance;
int radarAngle, radarDistance, index, Range = 60;

ToxiclibsSupport gfx;

void setup()
{
size (1366, 710);
gfx = new ToxiclibsSupport(this);
smooth();

//assigning port

myPort = new Serial(this, "COM3" , 9600);

13
Continued…

myPort.bufferUntil('#');
}
void draw()
{
//setting Background to black
fill(0, 4);
noStroke();
rect(0, 0, 1366, 710);

//Radar arc and lines

//pushMatrix();

translate(683, 660);
noFill();
strokeWeight(2);
stroke(10,255,10);
arc(0, 0, 1300, 1300, PI, TWO_PI);
arc(0, 0, 1050, 1050, PI, TWO_PI);
arc(0, 0, 720, 720, PI, TWO_PI);
arc(0, 0, 480, 480, PI, TWO_PI);
strokeWeight(4);
line(-683,0,683,0);

14
Continued…

line(0, 0, -591.5, -341.5);


line(0, 0, 0, -683);
line(0, 0, 591.5, -341.5);
line(0, 0, -341.5, -591.5);
line(0, 0, 341.5, -591.5);

//rotating arcs

RotatingArcs();

void RotatingArcs()
{
noStroke();
fill(10, 255, 10, 50);

arc(0, 0, 1300, 1300, -radians(radarAngle + .5), -radians(radarAngle - 0.5));

ObjectDistance = radarDistance*15;

if(radarDistance<Range){
noStroke();

15
Continued…

fill(255, 5, 5);
arc(0, 0, 1300, 1300, -radians(radarAngle + .5), -radians(radarAngle - 0.5));
fill(10, 255, 10);
arc(0, 0, ObjectDistance, ObjectDistance, -radians(radarAngle + .5), -radians(radarAngle - 0.5));
}

void serialEvent (Serial port)


{
//reads string and assigns to serial data variable
serialData = port.readStringUntil('#');
//removing # from end
serialData = serialData.substring(0,serialData.length()-1);
//Index of '*'
index = serialData.indexOf("*");

//seperating angle and distance


serialAngle= serialData.substring(0, index);
serialDistance= serialData.substring(index+1, serialData.length());

radarAngle = int(serialAngle);
radarDistance = int(serialDistance);
}

16
Image imported in Processing
code

17
WORK DISTRIBUTION
Himanshu Panwar Anurag Lakra
He managed to do all the work Anurag did all the assembling of
related to arduino code and also our project and made the video of
the weekly presentations. the working.

Shagun did the code part of


Processing software and also help He code the processing software
in arduino code. visuals along with shagun.
Shagun Katariya Harsh Saini

18
PROBLEMS & SOLUTIONS
We faced many problems like delay in components and faulty components but they
all were minor problems and were managed properly by the team members, but the
major problem we faced was to code the visuals on Processing software, as it was
bit new for all of us.

So to cope up with this problem we gave quite bit of time to learn the software and
watched several tutorials available online.

19
THANK YOU
From Team - 22

20

You might also like