SIMPLE RADAR WITH ARDUINO MEGA
Today in this article we are going to Make simple Radar with Arduino Mega , Servo Moto, and ultrasonic senso. Here you will get Fully Detailed instructions for making Arduino Joystick Controlled Car. Codes are also Included.
I have tried to provide you all the must-have Circuit Schematics and Diagrams in this article. My intention was to give you all in one guide for making joystick Car.
The radar can detect objects located at distances between 2 cm and 4 meters and displays the value of distance to the object. ... The object detection is performed inside an angle of 180 degrees. The motion sensor that covers this angle uses a Servo Motor.
If you want to make a School/ College project then this project is for you. You would not need any special knowledge for making the Arduino joystick control car. So, you should definitely try it.
WATCH YOUTUBE VIDEO
Watch the Full Video and you will understand everything. Next, follow the step by step guide below.
This project is based on Arduino radar (HC-SR04)
which is digitally visualized using Processing.
ARDUINO RADAR WORKING
The word RADAR means Radio Detection And Ranging. Radar is an object detection system that uses microwaves to determine the range, altitude, direction, and speed of objects within about a 100-mile radius of their location. The radar antenna transmits radio waves or microwaves that bounce off any object in their path. Due to this, we can easily determine the object in the radar range.The basic principle of operation:
A radar is an electromagnetic sensor that is used to detect and locate an object.Radio waves or microwaves are radiated out from the radar into free space. Some of these waves are intercepted by reflecting objects. These intercepted radio waves hit the target and are reflected in many different directions. Some of these waves can be directed back toward the radar, where they are received and amplified. If these waves are received again at their origin, then it means an object is in the propagation direction. The modern radar system is very advanced and used in highly diverse applications such as Air traffic control, Air-defence system, radar Astronomy, Antimissile system, Outer space Surveillance system, and many more.
COMPONENTS REQUIRED
Item Image |
Item Name |
Quantity |
Shop Online |
---|---|---|---|
Plywood 16cm X10cm |
1 No | Order Now | |
Arduino UNO |
1 No | Order Now | |
Servo Motor |
1 No | Order Now |
|
ultrasonic sensor |
1 No | Order Now |
|
Jumper wires |
Enough | Order Now |
Tools Required
Tool Image |
Tool Name |
Shop Online |
---|---|---|
Gun gum |
Order Now |
APPS AND ONLINE SERVICES
Arduino IDE |
Downlond now | |
---|---|---|
processing 3 |
Downlond now |
CIRCUIT DIAGRAM
circuit diagram of arduino radar
STEPS TO MAKING
I have divided the joystick control car into several steps. By this, you can understand the Arduino car more easily. Please don’t skip any step otherwise it will be difficult to replicate.
codes
Arduino code
// Includes the Servo library
#include <Servo.h>.
// Defines Tirg and Echo pins of the Ultrasonic Sensor
const int trigPin = 10;
const int echoPin = 11;
// Variables for the duration and the distance
long duration;
int distance;
Servo myServo; // Creates a servo object for controlling the servo motor
void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
Serial.begin(9600);
myServo.attach(12); // Defines on which pin is the servo motor attached
}
void loop() {
// rotates the servo motor from 15 to 165 degrees
for(int i=15;i<=165;i++){
myServo.write(i);
delay(30);
distance = calculateDistance();// Calls a function for calculating the distance measured by the Ultrasonic sensor for each degree
Serial.print(i); // Sends the current degree into the Serial Port
Serial.print(","); // Sends addition character right next to the previous value needed later in the Processing IDE for indexing
Serial.print(distance); // Sends the distance value into the Serial Port
Serial.print("."); // Sends addition character right next to the previous value needed later in the Processing IDE for indexing
}
// Repeats the previous lines from 165 to 15 degrees
for(int i=165;i>15;i--){
myServo.write(i);
delay(30);
distance = calculateDistance();
Serial.print(i);
Serial.print(",");
Serial.print(distance);
Serial.print(".");
}
}
// Function for calculating the distance measured by the Ultrasonic sensor
int calculateDistance(){
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH); // Reads the echoPin, returns the sound wave travel time in microseconds
distance= duration*0.034/2;
return distance;
}
// Includes the Servo library
#include <Servo.h>.
// Defines Tirg and Echo pins of the Ultrasonic Sensor
const int trigPin = 10;
const int echoPin = 11;
// Variables for the duration and the distance
long duration;
int distance;
Servo myServo; // Creates a servo object for controlling the servo motor
void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
Serial.begin(9600);
myServo.attach(12); // Defines on which pin is the servo motor attached
}
void loop() {
// rotates the servo motor from 15 to 165 degrees
for(int i=15;i<=165;i++){
myServo.write(i);
delay(30);
distance = calculateDistance();// Calls a function for calculating the distance measured by the Ultrasonic sensor for each degree
Serial.print(i); // Sends the current degree into the Serial Port
Serial.print(","); // Sends addition character right next to the previous value needed later in the Processing IDE for indexing
Serial.print(distance); // Sends the distance value into the Serial Port
Serial.print("."); // Sends addition character right next to the previous value needed later in the Processing IDE for indexing
}
// Repeats the previous lines from 165 to 15 degrees
for(int i=165;i>15;i--){
myServo.write(i);
delay(30);
distance = calculateDistance();
Serial.print(i);
Serial.print(",");
Serial.print(distance);
Serial.print(".");
}
}
// Function for calculating the distance measured by the Ultrasonic sensor
int calculateDistance(){
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH); // Reads the echoPin, returns the sound wave travel time in microseconds
distance= duration*0.034/2;
return distance;
}