Radar
Project Overview :
This project involves creating a radar-like system using an Arduino microcontroller, an ultrasonic sensor (HC-SR04), and a servo motor. The ultrasonic sensor is mounted on the servo motor, allowing it to rotate and measure distances in different directions. The Arduino controls the servo motor to scan the sensor's field of view, and the sensor detects objects and calculates their distances based on the time it takes for sound waves to bounce back. The Arduino then processes this data and displays it, simulating a radar display.
Material :
- Arduino board (e.g., Arduino Uno)
Circuit Setup:
- Connect the ultrasonic sensor to the Arduino board. The sensor typically has four pins: VCC, GND, Trigger, and Echo.
- Connect the VCC pin of the sensor to the 5V pin on the Arduino, and the GND pin to the GND pin.
- Connect the Trigger pin of the sensor to a digital pin (e.g., pin 9) on the Arduino.
- Connect the Echo pin of the sensor to another digital pin (e.g., pin 10) on the Arduino.
- Connect the servo motor to the Arduino to control the rotation of the sensor.
- Connect the control wire of the servo motor to a PWM pin (e.g., pin 3) on the Arduino.
Code :
#include <Servo.h>
#define TRIG_PIN 9
#define ECHO_PIN 10
#define SERVO_PIN 3
Servo servo;
void setup() {
Serial.begin(9600);
servo.attach(SERVO_PIN);
}
void loop() {
// Scan from 0 to 180 degrees
for (int angle = 0; angle <= 180; angle += 10) {
// Move the servo to the current angle
servo.write(angle);
delay(500); // Adjust the delay as needed
// Perform distance measurement
long duration, distance;
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
duration = pulseIn(ECHO_PIN, HIGH);
distance = duration * 0.034 / 2;
// Print the angle and distance
Serial.print("Angle: ");
Serial.print(angle);
Serial.print(" degrees, Distance: ");
Serial.print(distance);
Serial.println(" cm");
}
// Reset the servo to starting position
servo.write(90);
delay(1000); // Delay before next scan
}
Processing Code :
How it works ?
- The ultrasonic sensor is mounted on a servo motor, allowing it to rotate and measure distances in different directions.
- The Arduino rotates the servo motor in steps, scanning from 0 to 180 degrees.
- At each angle, the Arduino triggers the ultrasonic sensor to send out a sound wave and measures the time it takes for the wave to bounce back (the echo).
- Based on the time taken, the Arduino calculates the distance to any object in that direction.
- The Arduino then prints the angle and distance to the serial monitor for visualization.
Visualization:
Uses :
- Object Detection: The radar system can be used to detect objects in different directions, making it useful for applications such as obstacle detection and avoidance in robotics or autonomous vehicles.
- Surveillance: The radar system can be used for surveillance purposes, monitoring the presence of objects or individuals within a certain range.
- Security: It can be used as a security system to detect unauthorized intrusions or movements in restricted areas.
- Navigation: The radar system can assist in navigation by providing real-time information about obstacles or hazards in the environment, enabling safe and efficient movement.
- Environmental Monitoring: It can be used for environmental monitoring applications, such as monitoring the presence of objects or wildlife in natural habitats.
- Research and Development: The radar system can be used for research and development purposes, such as studying object detection algorithms, sensor fusion techniques, and autonomous navigation systems.
Overall, the Arduino-based radar system offers a versatile and cost-effective solution for various applications requiring object detection and monitoring capabilities.
***************************************************************************************************
Comments
Post a Comment