diff --git a/Domains/Robotics-Automation/MiniProjects/Radar-System/Radar System.pdf b/Domains/Robotics-Automation/MiniProjects/Radar-System/Radar System.pdf new file mode 100644 index 00000000..4ae75a4b Binary files /dev/null and b/Domains/Robotics-Automation/MiniProjects/Radar-System/Radar System.pdf differ diff --git a/Domains/Robotics-Automation/MiniProjects/Radar-System/code.ino b/Domains/Robotics-Automation/MiniProjects/Radar-System/code.ino new file mode 100644 index 00000000..0658329f --- /dev/null +++ b/Domains/Robotics-Automation/MiniProjects/Radar-System/code.ino @@ -0,0 +1,75 @@ +#include +#include +#include + +// LCD setup (address 0x27 is common, 16 columns x 2 rows) +LiquidCrystal_I2C lcd(0x27, 16, 2); + +Servo myServo; + +const int trigPin = 9; +const int echoPin = 10; + +long duration; +int distance; + +void setup() { + myServo.attach(3); + pinMode(trigPin, OUTPUT); + pinMode(echoPin, INPUT); + + lcd.init(); // Initialize LCD + lcd.backlight(); // Turn on backlight +} + +void loop() { + // Sweep from 0° to 180° + for (int pos = 0; pos <= 180; pos += 5) { + myServo.write(pos); + delay(200); + + distance = getDistance(); + + displayLCD(pos, distance); + } + + // Sweep from 180° to 0° + for (int pos = 180; pos >= 0; pos -= 5) { + myServo.write(pos); + delay(200); + + distance = getDistance(); + + displayLCD(pos, distance); + } +} + +// Function to measure distance +int getDistance() { + digitalWrite(trigPin, LOW); + delayMicroseconds(2); + + digitalWrite(trigPin, HIGH); + delayMicroseconds(10); + digitalWrite(trigPin, LOW); + + long duration = pulseIn(echoPin, HIGH); + int dist = duration * 0.034 / 2; // in cm + return dist; +} + +// Function to display angle and distance on LCD +void displayLCD(int angle, int distance) { + lcd.clear(); + lcd.setCursor(0, 0); + lcd.print("Angle: "); + lcd.print(angle); + lcd.print((char)223); // Degree symbol + + lcd.setCursor(0, 1); + lcd.print("Dist: "); + lcd.print(distance); + lcd.print(" cm"); + + delay(200); // Small delay so LCD is readable +} diff --git a/Domains/Robotics-Automation/MiniProjects/Radar-System/readme.md b/Domains/Robotics-Automation/MiniProjects/Radar-System/readme.md new file mode 100644 index 00000000..c1d962d4 --- /dev/null +++ b/Domains/Robotics-Automation/MiniProjects/Radar-System/readme.md @@ -0,0 +1,91 @@ +🛰️ Arduino Radar System + +The Arduino Radar System uses an ultrasonic sensor, servo motor, and LCD display to detect and display the distance of nearby objects at different angles. The servo motor continuously sweeps from 0° to 180°, while the ultrasonic sensor measures the distance and shows both the angle and distance on the LCD screen. + +⚙️ Components Used + +Arduino UNO (or compatible board) + +Ultrasonic Sensor (HC-SR04) + +Servo Motor (SG90 or similar) + +I2C LCD Display (16x2, address 0x27) + +Jumper Wires + +Breadboard + +🧠 Working Principle + +The servo motor rotates from 0° to 180°, scanning the area. + +At each step, the ultrasonic sensor measures the distance of any obstacle. + +The LCD display shows: + +Angle (°) of the servo + +Distance (cm) of the detected object + +The process repeats continuously to simulate a radar sweep. + +🔌 Pin Connections + + +| Component | Arduino Pin | Description | +| --------------- | ----------- | ----------------- | +| Servo Motor | D3 | PWM Signal | +| Ultrasonic Trig | D9 | Trigger Pin | +| Ultrasonic Echo | D10 | Echo Pin | +| LCD SDA | A4 | I2C Data | +| LCD SCL | A5 | I2C Clock | +| VCC & GND | 5V, GND | Power Connections | + + +💻 Code Overview + +The servo moves in a sweep motion (0° → 180° → 0°). + +Distance is calculated using ultrasonic sensor readings. + +Angle and distance are displayed on the LCD. + +🧩 Libraries Required + +Make sure you have these libraries installed in Arduino IDE: + +Servo.h + +Wire.h + +LiquidCrystal_I2C.h + +🚀 How to Run + +Connect the components as per the pin configuration. + +Upload the provided Arduino code. + +Power up your Arduino board. + +Watch the servo sweep while the LCD displays angle and distance readings. + +📊 Output Example + +Angle: 90° +Dist: 22 cm + +🌟 Features + +✅ Real-time distance measurement + +✅ Smooth servo sweep motion + +✅ Clear LCD display output + +✅ Simple and beginner-friendly project + +Author + +Shirsha Nag | IOT+Robotics developer