Expt 12
Expt 12
12
DESIGN AN IOT BASED SYSTEM
Date:
Aim
2 Arduino Uno R3 1
THEORY:
The Arduino Radar Project utilizes ultrasonic sensors and servo motors to replicate
the functionality of a radar system. Ultrasonic sensors emit waves and measure their
reflection time to determine object distances, while servo motors rotate the sensor module
akin to a radar antenna, expanding the detection area. Acting as the system's central
processing unit, the Arduino board interprets sensor data, computes object distances, and
orchestrates servo motor movements. Radar is a long-range object detection system that uses
radio waves to establish certain parameters of an object like its range, speed and position.
Radar technology is used in aircrafts, missiles, marine, weather predictions and automobiles.
Through this project, the fundamentals of radar technology merge with Arduino's
programming capabilities, offering an educational exploration into practical radar
implementation.
PROCEDURE:
Connect the VCC pin of the HC-SR04 to the +5V pin of the Arduino.
Connect the GND pin of the HC-SR04 to the GND pin of the Arduino.
Connect the Trigger pin of the HC-SR04 to a digital pin (e.g., pin 9) of the Arduino.
Connect the Echo pin of the HC-SR04 to another digital pin (e.g., pin 10) of the
Arduino.
Connect the Signal pin of the Servo Motor to a PWM-enabled pin (e.g., pin 11) of the
Arduino.
Connect the GND pin of the Servo Motor to the GND pin of the Arduino.
PROGRAM:
#include <Servo.h>
const int trigPin = 9;
const int echoPin = 10;
long duration;
int distinCM;
Servo radarServo;
void setup()
{
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
radarServo.attach(11);
}
void loop()
{
for(int i=0;i<=180;i++)
{
radarServo.write(i);
delay(50);
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distinCM = duration*0.034/2;
Serial.print(i);
Serial.print("*");
Serial.print(distinCM);
Serial.print("#");
}
for(int i=180;i>=0;i--)
{
radarServo.write(i);
delay(50);
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distinCM = duration*0.034/2;
Serial.print(i);
Serial.print("*");
Serial.print(distinCM);
Serial.print("#");
}
}