Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
75 changes: 75 additions & 0 deletions Domains/Robotics-Automation/MiniProjects/Radar System/code.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#include <Servo.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// 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
}
88 changes: 88 additions & 0 deletions Domains/Robotics-Automation/MiniProjects/Radar System/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
πŸ›°οΈ 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
Loading