The Radar on Road Vehicles project creates a simple radar system using an Arduino, ultrasonic sensor, servo motor, and buzzer. This innovative setup efficiently detects obstacles and alerts drivers, enhancing road safety. By leveraging Arduino control, the system scans a 180-degree area for obstacles and sounds a buzzer if an object is within 30 cm, demonstrating key principles of distance measurement and object detection in a practical, educational manner. This technology provides an affordable solution for developing intelligent vehicle systems, making it accessible for hobbyists and students alike. Additionally, it showcases the potential for integrating simple electronic components to achieve sophisticated functionality in real-world applications.
Components/Circuit:
- Ultrasonic Sensor: Measures distance to detect nearby obstacles.
- Servo Motor: Rotates the sensor to scan a 180-degree area.
- Arduino Board: Controls the radar system based on sensor data.
- Buzzer: Sounds an alert if an obstacle is detected within a specified range.
CODE
#include <Servo.h>
const int trigPin = 4;
const int echoPin = 3;
const int buzzerPin = 12;
Servo myServo;
long duration;
int distance;
void setup() {
Serial.begin(9600);
myServo.attach(5);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(buzzerPin, OUTPUT);
}
void loop() {
for (int pos = 0; pos <= 180; pos += 1) {
myServo.write(pos);
delay(15);
distance = calculateDistance();
if (distance < 30) { // If distance is less than 30 cm
digitalWrite(buzzerPin, HIGH);
} else {
digitalWrite(buzzerPin, LOW);
}
delay(200);
}
for (int pos = 180; pos >= 0; pos -= 1) {
myServo.write(pos);
delay(15);
distance = calculateDistance();
if (distance < 30) { // If distance is less than 30 cm
digitalWrite(buzzerPin, HIGH);
} else {
digitalWrite(buzzerPin, LOW);
}
delay(200);
}
}
int calculateDistance() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;
return distance;
}
How it Works:
- Scanning Area: The servo motor rotates the ultrasonic sensor to scan a 180-degree area.
- Measuring Distance: The ultrasonic sensor measures distances to detect obstacles.
- Alerting: The Arduino processes sensor data and activates the buzzer if an obstacle is within 30 cm.
Benefits:
- Enhanced Safety: Alerts drivers to nearby obstacles, reducing the risk of collisions.
- Educational Tool: Demonstrates principles of distance measurement and object detection.
- Automation: Provides continuous monitoring without manual intervention.
- Efficiency: Improves vehicle safety with minimal hardware and simple setup.
- Cost-Effective: Offers an affordable method for developing intelligent vehicle systems.
Application: Ideal for educational projects, vehicle safety demonstrations, and DIY electronics enthusiasts, the Radar on Road Vehicles system offers a practical and accessible way to understand and implement basic radar technology for obstacle detection and collision prevention. It is also suitable for prototyping in automotive innovations, fostering creativity and learning in technological development.