Radar using arduino
Slide 2: Introduction
1.Radar technology has been pivotal in many fields, such as aviation,
weather monitoring, and automotive applications. It works by sending out waves—
electromagnetic, sound, or light—and then analyzing the waves that bounce back after
encountering objects. This principle is applied in radar systems to calculate distances, detect
objects, and create maps.
2.In this project, we explore how to build a basic radar system using an
ultrasonic sensor and Arduino. The ultrasonic sensor emits sound waves, and by measuring the
time it takes for the waves to reflect back, we can calculate the distance to nearby objects. The
Arduino controls the sensor and a servo motor to create a simple radar system.
3.This setup can be used to measure distances in various directions,
simulating radar scans. With this project, we aim to demonstrate how sensors, microcontrollers,
and motors work together to simulate radar functionality at a very basic level. While this radar
system is relatively simple, it lays the foundation for more complex radar systems used in robotics,
autonomous vehicles, and other applications.
Slide 3: Components Used
1.Arduino Board (e.g., Arduino Uno or Nano): The microcontroller that will control the servo motor and
ultrasonic sensor.
2.Ultrasonic Sensor (HC-SR04): This sensor uses sound waves to detect objects and measure distance. It
sends a pulse, and the time it takes for the pulse to return is used to calculate the distance.
3.Servo Motor: The motor rotates the ultrasonic sensor to different angles, allowing the radar to scan
multiple directions. A servo motor is chosen because it allows precise control over its rotation angle.
4.Jumper Wires: These are used to make the necessary electrical connections between the components
and the Arduino board.
5.Breadboard (Optional): This is used to organize and connect components without the need for
soldering.
6.Power Supply: A stable power source is necessary to power the Arduino, ultrasonic sensor, and servo
motor. A 5V power supply is generally sufficient for these components.
Slide 4: Ultrasonic Sensor Working Principle
1.The HC-SR04 ultrasonic sensor operates on the principle of echolocation. It emits an
ultrasonic pulse from the Trigger pin and waits for the pulse to bounce back, detected by the Echo pin.
2.The time it takes for the pulse to return is proportional to the distance of the object.
The speed of sound in air is approximately 343 meters per second, but in this system, we’ll calculate it in
centimeters, where the speed is about 0.0344 cm/μs. The time is measured in microseconds, and the
distance is calculated using the formula:
Distance (cm) = (Duration * Speed of Sound) / 2
1.The division by 2 accounts for the round-trip travel time of the pulse. The sensor has a
range from 2 cm to 400 cm. The trigger pin is first set to LOW, then to HIGH to send the pulse, followed by
setting it back to LOW again.
2. The time between sending the pulse and receiving the echo is measured using
pulseIn() in Arduino, and from this, we calculate the distance to the object. This method of measuring
distance is quick and efficient, making ultrasonic sensors ideal for simple radar applications.
Slide 5: Servo Motor
1.A servo motor is a type of motor that allows for precise control of angular
position. In this radar project, the servo motor is used to rotate the ultrasonic sensor. By rotating the
sensor from 0° to 180°, the system can scan a wide area and collect distance data at different angles.
2.This movement is controlled by the Arduino through a PWM (Pulse Width
Modulation) signal sent to the servo’s control pin.
3.The servo motor’s movement is controlled by adjusting the width of the PWM
pulse, where the pulse width corresponds to the position of the motor. For example, a 0° position
might correspond to a 1ms pulse, while a 180° position corresponds to a 2ms pulse.Servos are
designed for high precision, so they are ideal for applications where the rotation angle needs to be
controlled accurately.
4.In this radar setup, the servo motor will rotate the ultrasonic sensor at regular
intervals (e.g., every 1° or 5°) to scan the environment in a full 180° range. Each time the servo rotates
to a new position, the ultrasonic sensor measures the distance to any nearby objects.
5.The servo motor helps achieve the sweeping motion necessary to collect distance
data from multiple angles, essentially mimicking the behavior of a radar system.
Slide 6: How the Radar System Works
The radar system works by rotating the ultrasonic sensor to various angles and measuring the distance at each
position. The process works as follows:
1.Servo Rotation: The servo motor moves the ultrasonic sensor to a specific angle, usually ranging from 0° to 180°.
2.Ultrasonic Emission: Once the servo reaches a position, the Arduino triggers the ultrasonic sensor to emit a pulse.
3.Echo Reception: The sensor waits for the echo to return. The time it takes for the pulse to bounce back is
recorded.
4.Distance Calculation: The Arduino uses the measured time to calculate the distance to the object.
5.Data Output: The calculated distance is sent to the Serial Monitor, or it could be displayed on an LCD screen,
allowing real-time feedback on the detected objects.
6.Repeat Process: The servo rotates to the next angle, and the process repeats.
As the servo rotates, the radar system continuously collects distance measurements at different angles. This allows
the system to create a simple scan of its environment. The radar system can be expanded further to include more
sensors, better resolution, or even continuous scanning for dynamic systems like robotics.
Slide 7: Circuit Diagram
The circuit diagram of the radar system is essential for understanding how the components connect to
each other.
1.Ultrasonic Sensor Connections:
1. VCC pin of the sensor connects to 5V on the Arduino to power the sensor.
2. GND pin connects to GND on the Arduino.
3. Trig pin is connected to Pin 9 on the Arduino, used to trigger the pulse.
4. Echo pin is connected to Pin 10 on the Arduino, which receives the echo signal.
2.Servo Motor Connections:
1. VCC pin of the servo connects to 5V on the Arduino to provide power.
2. GND pin connects to GND on the Arduino.
3. Signal pin connects to Pin 11 on the Arduino, used to control the motor's position.
The Arduino board is the center of the setup, receiving data from the ultrasonic sensor and
controlling the servo motor’s movement. The correct wiring of each component ensures that the
radar system functions properly. Using jumper wires and a breadboard helps in organizing the
connections and preventing any mistakes during setup.
Slide 8: Arduino Code Overview
The Arduino code for the radar system is divided into setup and loop functions.
1.Pin Initialization: In the setup() function, we define the pins used for the ultrasonic sensor and servo
motor. The Serial.begin(9600) function initializes communication between the Arduino and the Serial
Monitor, allowing us to view the results.
2.Servo Motor Control: We use the Servo library to control the rotation of the servo motor. The
myServo.write() function sends PWM signals to the servo to move it to the desired position.
3.Distance Measurement: The ultrasonic sensor is triggered using the digitalWrite() function. The echo
time is measured using pulseIn(), which returns the time taken for the pulse to return to the sensor. This
time is then converted to distance using the appropriate formula.
4.Data Display: The calculated distance is printed to the Serial Monitor using Serial.print() and
Serial.println().
5.Scanning Loop: The loop() function rotates the servo from 0° to 180° (or any desired range), measures
the distance, and outputs the result for each angle. After completing the full sweep, the servo returns to
0° and begins scanning again.
Slide 9: Arduino Code Explained (Part 1)
The code begins with defining the pins and including the
necessary libraries:
#include <Servo.h>
const int trigPin = 9;
const int echoPin = 10;
const int servoPin = 11;
Servo myServo;
1.Include Servo Library:
The Servo.h library is included to easily control the servo motor.
2.Define Pins:
We define the digital pins connected to the ultrasonic sensor's trigger and echo pins, as
well as the servo motor's control pin.
3.Create Servo Object:
The Servo myServo object will be used to control the servo motor.
1.Next, the setup() function sets up the sensor and motor:
void setup() {
Serial.begin(9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
myServo.attach(servoPin);
•Initialize Serial Communication:
}
Serial.begin(9600) starts communication with the Serial Monitor for debugging and
displaying results.
•Set Pin Modes:
The trigger pin is set as OUTPUT, and the echo pin is set as INPUT to receive the
reflected signal.
•Attach Servo:
The myServo.attach(servoPin) command connects the servo motor to the specified .
Slide 10: Arduino Code Explained (Part 2)
In the loop() function, the radar system performs the scanning and measurement tasks:
void loop() {
for (angle = 0; angle <= 180; angle++) {
myServo.write(angle);
delay(15); // Allow time for servo to reach position
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.0344 / 2; // Distance in cm
Serial.print("Angle: ");
Serial.print(angle);
Serial.print("° - Distance: ");
Serial.print(distance);
Serial.println(" cm");
delay(200); // Delay for smoother servo motion
}
myServo.write(0); // Return servo to start position
delay(1000); // Delay before starting new scan
}
Slide 11: Output – Serial Monitor
Once the system runs, the data will be shown in the Serial Monitor in the following format:
Angle: 0° - Distance: 120 cm
Angle: 1° - Distance: 118 cm
Angle: 2° - Distance: 115 cm
...
Angle: 180° - Distance: 75 cm
This output displays the angle and the distance to the nearest object detected by the ultrasonic
sensor at that specific angle.
By analyzing this data, we can determine the position of objects relative to the radar system. The
angle increases from 0° to 180°, and for each angle, the distance is measured and displayed.
This data can be used for object detection or for building a simple radar map.
Slide 13: Applications of Radar Systems
1.Autonomous Vehicles:
In autonomous cars, radar systems (often using ultrasonic or LIDAR sensors)
are used for detecting obstacles, measuring distances, and mapping the surrounding environment to
aid in navigation. The basic radar system we’ve built can be adapted for use in parking assist or
collision detection in autonomous vehicles.
2.Robotics and Drones:
Robots and drones can benefit from radar systems to navigate their
environment by detecting objects in real-time. For example, the radar system can be used for path
planning, collision avoidance, and area mapping. Robots can use radar to create 3D maps of their
surroundings or avoid obstacles during navigation.
3.Surveillance and Security:
Radar systems can be used for surveillance, detecting movement and
measuring distances of intruders. For example, radar-based security systems are used in perimeter
defense and motion detection to monitor activity in restricted areas. A radar system like this can
also be used in industrial settings for safety monitoring and equipment protection.
Weather radar:
Systems, such as Doppler radar, detect precipitation and measure its intensity.
Although the radar system in this project is much simpler, the concept is similar to how weather
radars are used to monitor weather patterns like rain, snow, and tornado formation.
Medical and Healthcare:
Ultrasonic technology is already widely used in medical applications, such as
ultrasound imaging. While this radar system is designed for object detection, similar principles
can be used in healthcare for medical diagnostics, such as detecting tumors or measuring
blood flow with specialized sensors.
Environmental Monitoring:
Radar systems can be used in environmental monitoring to detect changes
in the landscape, measure soil moisture, or even monitor vegetation health. Radar can also be
used to measure the distance and size of objects like trees or buildings in remote sensing
applications.
THANK YOU