. SmartElectronicsDIY

Automatic Fire Detection Suppression System(Arduino Uno | Embedded + Safety System)

This system automatically detects fire using flame and smoke sensors and activates a water pump to suppress it. At the same time, it triggers an alarm and can send alerts (optional GSM/IoT).

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

Smart Clothes Drying System using Arduino (Rain + Servo)

 This project automatically protects clothes from rain:

  • 🌧️ Rain detected → Clothes move inside (90°)
  • ☀️ Rain stops → Clothes move outside (0°)

🧰 Components Required

ComponentQuantity
Arduino UNO1
Rain Sensor Module (YL-83)1
Servo Motor (MG995 recommended)1
Breadboard1
Jumper WiresAs needed
5V External Power Supply1
Rod / Frame (for model)1

🔌 Circuit Connections

🌧️ Rain Sensor → Arduino

  • VCC → 5V
  • GND → GND
  • DO → Pin 2

🔄 Servo Motor → Arduino

  • Red → 5V (External supply recommended ⚠️)
  • Brown/Black → GND
  • Yellow/Orange → Pin 9

👉 Important:
Connect Arduino GND and external supply GND together


⚙️ Working Explanation

  1. Rain sensor detects water droplets
  2. Arduino reads signal
  3. If rain:
    • Servo rotates to 90°
    • Clothes move inside
  4. If no rain:
    • Servo rotates back to
    • Clothes go outside

💻 Full Arduino Code

#include <Servo.h>

Servo myServo;

int rainSensor = 2;
int rainStatus = 0;

void setup() {
pinMode(rainSensor, INPUT);
myServo.attach(9);

Serial.begin(9600);

myServo.write(0); // Start outside
}

void loop() {
rainStatus = digitalRead(rainSensor);

if (rainStatus == LOW) { // Rain detected
Serial.println("🌧️ Rain Detected → Moving Inside");
myServo.write(90); // Move inside
delay(2000);
}
else {
Serial.println("☀️ No Rain → Moving Outside");
myServo.write(0); // Move outside
delay(2000);
}

delay(500);
}

🧪 Output Result

ConditionAction
Rain detected 🌧️Servo → 90° (Clothes inside)
No rain ☀️Servo → 0° (Clothes outside)

🏗️ Model Design (How to Make)

👉 Simple DIY idea:

  • Use cardboard base
  • Attach a rod (hanger pipe)
  • Connect servo to rod joint
  • Make it rotate like a door (90° swing)

🖼️ What Your Project Should Look Like

Imagine:


🚀 Advanced Version (For High Marks 🔥)

Add these:

Broken Track Detection System for Train Accident Prevention

 

 Project Introduction

Railway accidents due to broken or cracked tracks are one of the major safety issues in rail transport. To solve this problem, we design a Smart Broken Track Detection System using Arduino, GSM, GPS, LCD and IoT technologies.

This system continuously checks the continuity of railway tracks. If any crack or break occurs, the system instantly detects it and sends alert messages to railway authorities with the exact GPS location.


📝 2. Detailed Article 

The Broken Track Detection System is an advanced railway safety project designed to prevent train accidents caused by damaged or cracked tracks. Railway tracks can develop faults due to environmental conditions, heavy load, or poor maintenance. These faults are difficult to detect manually, especially in remote areas. This project provides an automated and reliable solution.

The system is built using an Arduino microcontroller, which continuously monitors the electrical continuity of the railway track. Under normal conditions, current flows through the rails. When a crack or break occurs, the circuit gets interrupted, and the Arduino detects the change immediately.

Once a fault is detected, the system activates multiple safety actions. A buzzer alert and red LED are turned on to indicate danger. At the same time, a GSM module sends an SMS alert to railway authorities. The message includes the exact location using GPS module, which helps in quick maintenance response.

A 16x2 LCD display is used to show real-time track status, such as "Track Safe" or "Track Broken". Additionally, the system can send data to IoT cloud platforms like ThingSpeak or Blynk, enabling remote monitoring of railway track conditions.

This project is low-cost, efficient, and easy to implement on real railway lines. It significantly reduces human effort and improves safety by providing real-time fault detection and communication.

Overall, this system demonstrates how embedded systems and IoT technology can be used to enhance railway safety and prevent accidents.


🎯 3. Objectives of Project

  • Detect broken railway tracks automatically

  • Prevent train accidents

  • Send real-time alert to authorities

  • Provide exact GPS location

  • Enable remote monitoring using IoT


🔧 4. Components Required

ComponentQuantity
Arduino Uno1
SIM800L GSM Module1
NEO-6M GPS Module1
16x2 LCD Display1
Buzzer1
Red LED1
Green LED1
Resistors5
Jumper wiresAs required
Breadboard1
Power Supply5V
Track Model (metal strip)1

Arduino Pin Connections

🟢 Basic Components

ComponentArduino Pin
Track Detection WireD4
Green LED (+)D7
Red LED (+)D6
Buzzer (+)D8

👉 All LED (-) and Buzzer (-) → GND


📟 LCD 16x2 Connection (4-bit mode)

LCD PinArduino
RSD9
END10
D4D11
D5D12
D6D13
D7A0
VSSGND
VDD5V
RWGND
VOPotentiometer

📲 GSM SIM800L

GSM PinArduino
TXD2
RXD3
GNDGND
VCC4V External Supply ⚠️

📍 GPS NEO-6M

GPS PinArduino
TXD5
RXD6 ⚠️ (use voltage divider)
VCC5V
GNDGND

🌐 ESP8266 (IoT)

ESP8266Arduino
TXA1
RXA2
VCC3.3V
GNDGND

💻 2. Full Arduino Code (All Features)

/*
🚆 SMART BROKEN TRACK DETECTION SYSTEM
Features:
✔ Track Detection
✔ LCD Display
✔ GSM SMS Alert
✔ GPS Location
✔ IoT Cloud Output
*/

#include <SoftwareSerial.h>
#include <LiquidCrystal.h>

// Pin Setup
#define trackPin 4
#define greenLED 7
#define redLED 6
#define buzzer 8

LiquidCrystal lcd(9,10,11,12,13,A0);

// GSM
SoftwareSerial gsm(2,3);

// GPS
SoftwareSerial gps(5,6);

// ESP8266
SoftwareSerial wifi(A1,A2);

String latitude = "";
String longitude = "";

void setup()
{
pinMode(trackPin, INPUT);
pinMode(greenLED, OUTPUT);
pinMode(redLED, OUTPUT);
pinMode(buzzer, OUTPUT);

Serial.begin(9600);
gsm.begin(9600);
gps.begin(9600);
wifi.begin(9600);

lcd.begin(16,2);
lcd.print("Railway Safety");
delay(2000);
lcd.clear();
}

void loop()
{
int track = digitalRead(trackPin);

if(track == HIGH)
{
// SAFE CONDITION
digitalWrite(greenLED, HIGH);
digitalWrite(redLED, LOW);
digitalWrite(buzzer, LOW);

lcd.setCursor(0,0);
lcd.print("Track Status:");
lcd.setCursor(0,1);
lcd.print("SAFE ");

sendToCloud("SAFE");

delay(1000);
}
else
{
// BROKEN TRACK
digitalWrite(greenLED, LOW);
digitalWrite(redLED, HIGH);
digitalWrite(buzzer, HIGH);

lcd.setCursor(0,0);
lcd.print("TRACK BROKEN!");
lcd.setCursor(0,1);
lcd.print("Sending Alert");

getGPS();
sendSMS();
sendToCloud("BROKEN");

delay(5000);
}
}

// 📍 GPS Function
void getGPS()
{
while(gps.available())
{
String data = gps.readStringUntil('\n');

if(data.indexOf("$GPGGA") >= 0)
{
int latIndex = data.indexOf(",")+1;
int lonIndex = data.indexOf(",", latIndex+1);

latitude = data.substring(latIndex, latIndex+9);
longitude = data.substring(lonIndex, lonIndex+9);
}
}
}

// 📲 GSM SMS Function
void sendSMS()
{
gsm.println("AT+CMGF=1");
delay(1000);

gsm.println("AT+CMGS=\"+91XXXXXXXXXX\"");
delay(1000);

gsm.print("ALERT! TRACK BROKEN ");
gsm.print("Lat:");
gsm.print(latitude);
gsm.print(" Lon:");
gsm.print(longitude);

gsm.write(26);
delay(5000);
}

// 🌐 IoT Cloud Function
void sendToCloud(String status)
{
Serial.println("Uploading to IoT");

// Example ThingSpeak API
/*
wifi.println("AT+CIPSTART=\"TCP\",\"api.thingspeak.com\",80");
delay(2000);

String url = "GET /update?api_key=YOUR_API_KEY&field1=" + status;
wifi.print("AT+CIPSEND=");
wifi.println(url.length()+2);
delay(2000);

wifi.println(url);
*/
}

✅ Final Output Working

When track is safe
🟢 Green LED ON
📟 LCD = SAFE

When track breaks
🔴 Red LED ON
🔔 Buzzer ON
📲 SMS sent
📍 GPS location sent
🌐 IoT updated
📟 LCD shows alert


🎯 Your Project is Now 10Arduino Pin Connections

🟢 Basic Components

ComponentArduino Pin
Track Detection WireD4
Green LED (+)D7
Red LED (+)D6
Buzzer (+)D8

👉 All LED (-) and Buzzer (-) → GND


📟 LCD 16x2 Connection (4-bit mode)

LCD PinArduino
RSD9
END10
D4D11
D5D12
D6D13
D7A0
VSSGND
VDD5V
RWGND
VOPotentiometer

📲 GSM SIM800L

GSM PinArduino
TXD2
RXD3
GNDGND
VCC4V External Supply ⚠️

📍 GPS NEO-6M

GPS PinArduino
TXD5
RXD6 ⚠️ (use voltage divider)
VCC5V
GNDGND

🌐 ESP8266 (IoT)

ESP8266Arduino
TXA1
RXA2
VCC3.3V
GNDGND

💻 2. Full Arduino Code (All Features)

/*
🚆 SMART BROKEN TRACK DETECTION SYSTEM
Features:
✔ Track Detection
✔ LCD Display
✔ GSM SMS Alert
✔ GPS Location
✔ IoT Cloud Output
*/

#include <SoftwareSerial.h>
#include <LiquidCrystal.h>

// Pin Setup
#define trackPin 4
#define greenLED 7
#define redLED 6
#define buzzer 8

LiquidCrystal lcd(9,10,11,12,13,A0);

// GSM
SoftwareSerial gsm(2,3);

// GPS
SoftwareSerial gps(5,6);

// ESP8266
SoftwareSerial wifi(A1,A2);

String latitude = "";
String longitude = "";

void setup()
{
pinMode(trackPin, INPUT);
pinMode(greenLED, OUTPUT);
pinMode(redLED, OUTPUT);
pinMode(buzzer, OUTPUT);

Serial.begin(9600);
gsm.begin(9600);
gps.begin(9600);
wifi.begin(9600);

lcd.begin(16,2);
lcd.print("Railway Safety");
delay(2000);
lcd.clear();
}

void loop()
{
int track = digitalRead(trackPin);

if(track == HIGH)
{
// SAFE CONDITION
digitalWrite(greenLED, HIGH);
digitalWrite(redLED, LOW);
digitalWrite(buzzer, LOW);

lcd.setCursor(0,0);
lcd.print("Track Status:");
lcd.setCursor(0,1);
lcd.print("SAFE ");

sendToCloud("SAFE");

delay(1000);
}
else
{
// BROKEN TRACK
digitalWrite(greenLED, LOW);
digitalWrite(redLED, HIGH);
digitalWrite(buzzer, HIGH);

lcd.setCursor(0,0);
lcd.print("TRACK BROKEN!");
lcd.setCursor(0,1);
lcd.print("Sending Alert");

getGPS();
sendSMS();
sendToCloud("BROKEN");

delay(5000);
}
}

// 📍 GPS Function
void getGPS()
{
while(gps.available())
{
String data = gps.readStringUntil('\n');

if(data.indexOf("$GPGGA") >= 0)
{
int latIndex = data.indexOf(",")+1;
int lonIndex = data.indexOf(",", latIndex+1);

latitude = data.substring(latIndex, latIndex+9);
longitude = data.substring(lonIndex, lonIndex+9);
}
}
}

// 📲 GSM SMS Function
void sendSMS()
{
gsm.println("AT+CMGF=1");
delay(1000);

gsm.println("AT+CMGS=\"+91XXXXXXXXXX\"");
delay(1000);

gsm.print("ALERT! TRACK BROKEN ");
gsm.print("Lat:");
gsm.print(latitude);
gsm.print(" Lon:");
gsm.print(longitude);

gsm.write(26);
delay(5000);
}

// 🌐 IoT Cloud Function
void sendToCloud(String status)
{
Serial.println("Uploading to IoT");

// Example ThingSpeak API
/*
wifi.println("AT+CIPSTART=\"TCP\",\"api.thingspeak.com\",80");
delay(2000);

String url = "GET /update?api_key=YOUR_API_KEY&field1=" + status;
wifi.print("AT+CIPSEND=");
wifi.println(url.length()+2);
delay(2000);

wifi.println(url);
*/
}

✅ Final Output Working

When track is safe
🟢 Green LED ON
📟 LCD = SAFE

When track breaks
🔴 Red LED ON
🔔 Buzzer ON
📲 SMS sent
📍 GPS location sent
🌐 IoT updated
📟 LCD shows alert



Smart Arduino-Based Glasses for Blind

Project Purpose

Smart Arduino-Based Glasses for the Blind are an innovative wearable device designed to assist visually impaired individuals in navigating their surroundings safely. Unlike traditional walking sticks, these smart glasses detect obstacles at head level, helping users avoid hazards such as hanging objects, walls, or moving obstacles.

The system is built using the microcontroller Arduino Nano, which acts as the brain of the device. It is connected to ultrasonic sensors mounted on the front of the glasses. These sensors continuously measure the distance between the user and nearby objects by sending ultrasonic sound waves and receiving the reflected signals.

When an obstacle is detected within a predefined distance, the Arduino processes the data and immediately alerts the user through a small buzzer or vibration module attached to the frame. The alert intensity can vary depending on how close the object is, allowing the user to react quickly and safely.

The glasses are lightweight, portable, and designed for daily use. They can be powered by a small rechargeable battery, making them convenient and energy efficient. Additional features such as voice feedback, Bluetooth connectivity, or GPS navigation can also be integrated for enhanced functionality.

In conclusion, Smart Arduino-Based Glasses provide a modern, hands-free solution for visually impaired people. By combining sensors, electronics, and wearable design, this project enhances safety, independence, and confidence, helping users move freely in both indoor and outdoor environments.


🔧 Main Components Required

🧠 Controller

  1. Arduino Nano (recommended)

    • Small size, lightweight

    • Perfect for wearable projects
      (Arduino Uno can also be used for demo)


📡 Sensors

  1. Ultrasonic Sensor – HC-SR04

    • Detects obstacles (2 cm – 400 cm)

    • Mounted on the front of glasses

(Optional advanced option)

  • VL53L0X ToF Distance Sensor (more accurate, smaller)


🔔 Alert / Feedback System

  1. Buzzer (Active Buzzer)

    • Beeps faster as obstacle gets closer

  2. Vibration Motor (3V/5V)

    • Silent alert option (very useful for blind users)

(You can use buzzer OR vibration OR both)


🔊 Audio (Optional – Advanced)

  1. Mini Speaker

  2. DFPlayer Mini MP3 Module

    • Provides voice alerts like “Obstacle Ahead”


🔋 Power Supply

  1. 3.7V Li-ion / Li-Po Battery

  2. TP4056 Charging Module (with protection)

  3. Boost Converter (MT3608) (if needed for 5V)


🧰 Supporting Components

  1. Resistors (220Ω, 1kΩ)

  2. NPN Transistor (BC547 / 2N2222) – for vibration motor

  3. Diode (1N4007) – motor protection

  4. Slide Switch – power ON/OFF

  5. Jumper Wires

  6. Small Perf Board / PCB


👓 Mechanical

  1. Spectacles Frame (normal or 3D printed)

  2. Small Enclosure for Arduino & battery

  3. Cable ties / hot glue


⚙️ Optional Advanced Add-Ons

  • ESP32-CAM – object detection

  • Bluetooth Module (HC-05) – mobile voice output

  • GPS + GSM – emergency location alerts


📊 Component Summary Table

ComponentQuantity
Arduino Nano1
Ultrasonic Sensor HC-SR041
Buzzer1
Vibration Motor1
Li-ion Battery1
TP4056 Charger1
Switch1
Transistor + Diode1 set
Jumper WiresAs required

 

Smart Blind Stick Using Arduino

 

📌 Introduction

A Smart Blind Stick using Arduino is an innovative assistive device designed to help visually impaired people walk safely and independently. Traditional white canes only detect obstacles when they touch them, but a smart stick can sense objects from a distance and alert the user in advance.


This project is based on the popular microcontroller board Arduino Uno, which controls the entire system. The stick is equipped with an ultrasonic sensor that continuously measures the distance between the user and nearby obstacles. When an object is detected within a certain range, the system alerts the user using a buzzer or vibration motor.

The working principle is simple: the ultrasonic sensor sends high-frequency sound waves, which reflect back after hitting an obstacle. The Arduino calculates the time taken for the echo to return and converts it into distance. If the distance is below a set threshold, the buzzer starts beeping faster or the motor vibrates more strongly, warning the user about the obstacle.

This smart device is lightweight, portable, and cost-effective, making it suitable for real-life use. It can also be upgraded with additional features like GPS tracking, water detection, and voice alerts for better functionality.

In conclusion, the Smart Blind Stick using Arduino is a practical and life-changing project. It combines electronics and innovation to improve the mobility, safety, and confidence of visually impaired individuals, making their daily lives easier and more independent.


🎯 Objectives

  • Detect obstacles in front of the user

  • Alert using sound or vibration

  • Improve mobility and safety for blind people


🧰 Components Required

ComponentQuantity
Arduino UNO1
Ultrasonic Sensor (HC-SR04)1
Buzzer1
Vibration Motor (optional)1
Battery (9V or power bank)1
Jumper WiresAs needed
Stick (PVC pipe or walking stick)1
Breadboard1

⚙️ Working Principle

  1. The ultrasonic sensor sends sound waves.

  2. The waves reflect back from nearby objects.

  3. Arduino calculates the distance.

  4. If the object is near:

    • Buzzer beeps faster

    • Vibration motor vibrates

  5. If no obstacle → no alert


🔌 Circuit Connections

Ultrasonic Sensor → Arduino

  • VCC → 5V

  • GND → GND

  • Trig → Pin 9

  • Echo → Pin 10

Buzzer

  • Positive → Pin 6

  • Negative → GND

Vibration Motor (optional)

  • Positive → Pin 7

  • Negative → GND


💻 Arduino Code

#define trigPin 9
#define echoPin 10
#define buzzer 6
#define motor 7

long duration;
int distance;

void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(buzzer, OUTPUT);
pinMode(motor, OUTPUT);
Serial.begin(9600);
}

void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);

digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;

Serial.print("Distance: ");
Serial.println(distance);

if (distance < 100 && distance > 50) {
tone(buzzer, 500);
digitalWrite(motor, HIGH);
delay(300);
noTone(buzzer);
digitalWrite(motor, LOW);
delay(300);
}
else if (distance <= 50) {
tone(buzzer, 1000);
digitalWrite(motor, HIGH);
}
else {
noTone(buzzer);
digitalWrite(motor, LOW);
}

delay(100);
}

🧠 Block Diagram

Ultrasonic Sensor → Arduino → Buzzer
→ Vibration Motor
→ Serial Monitor

Prevention of Railway Accidents Using Arduino Uno

 Railway transportation is one of the most widely used and economical modes of travel, especially in countries like India. However, railway accidents caused by track damage, human error, or obstacles on the track can lead to serious loss of life and property. To address this issue, a smart safety system based on the Arduino Uno can be implemented to detect potential hazards and prevent accidents before they occur.




The proposed system uses sensors such as infrared (IR) sensors and ultrasonic sensors to monitor the condition of railway tracks and detect any obstacles. IR sensors are placed along the track to identify cracks or discontinuities, while the ultrasonic sensor measures the distance of any object present on the track. When a fault or obstacle is detected, the Arduino Uno processes the data and immediately activates a buzzer and warning lights to alert nearby personnel.

In addition to local alerts, the system can be integrated with a GSM module to send real-time notifications to railway authorities, allowing for quick action. A relay module is also used to automatically stop the train motor in case of danger, preventing collisions or derailments.

This Arduino-based solution is cost-effective, reliable, and easy to implement. It reduces human dependency and enhances railway safety through automation and real-time monitoring. With further improvements such as GPS tracking and IoT connectivity, this system can play a significant role in modernizing railway safety infrastructure and saving lives.


Introduction

Railway accidents often happen due to:

  • Track cracks

  • Collisions between trains

  • Human errors

  • Obstacles on track

This project uses an Arduino Uno–based smart safety system that can:

  • Detect cracks in railway tracks

  • Detect obstacles on track

  • Automatically alert railway control room

  • Stop train to avoid accidents


🎯 2. Objective

To design a low-cost smart railway safety system using Arduino that can:

  • Detect track damage

  • Detect obstacles

  • Send alerts

  • Prevent train collision


⚙️ 3. Components Required

ComponentQuantity
Arduino Uno1
Ultrasonic Sensor (HC-SR04)1
IR Sensor Module2
Buzzer1
LED (Red + Green)2
GSM Module (SIM800L/900A)1
Relay Module1
DC Motor (Train simulation)1
Battery / Power Supply1
Connecting wiresAs required
Breadboard1

🧠 4. System Working Principle

🔍 A. Track Crack Detection

  • IR sensors are placed along the railway track.

  • If a crack occurs, the IR signal breaks.

  • Arduino detects this and sends an alert.

🚧 B. Obstacle Detection

  • Ultrasonic sensor detects objects on track.

  • If distance < threshold (e.g., 20 cm), it triggers alarm.

📡 C. Alert System

  • GSM module sends SMS to railway authority.

  • Buzzer + Red LED alerts nearby people.

🛑 D. Automatic Train Stop

  • Relay cuts off motor power (train stops).


🔌 5. Block Diagram

IR Sensors ─┐
├──> Arduino Uno ───> Relay ──> Motor (Train)
Ultrasonic ─┘ │
├──> GSM Module (SMS Alert)
├──> Buzzer
└──> LED Indicator

🔗 6. Circuit Connections

Ultrasonic Sensor (HC-SR04)

  • VCC → 5V

  • GND → GND

  • Trig → Pin 9

  • Echo → Pin 10

IR Sensors

  • Output → Pin 2 and Pin 3

Relay Module

  • IN → Pin 7

Buzzer

    • → Pin 6

LEDs

  • Red → Pin 4

  • Green → Pin 5

GSM Module

  • TX → Pin 11

  • RX → Pin 12


💻 7. Arduino Code

#define trigPin 9
#define echoPin 10
#define ir1 2
#define ir2 3
#define buzzer 6
#define relay 7
#define redLED 4
#define greenLED 5

long duration;
int distance;

void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(ir1, INPUT);
pinMode(ir2, INPUT);
pinMode(buzzer, OUTPUT);
pinMode(relay, OUTPUT);
pinMode(redLED, OUTPUT);
pinMode(greenLED, OUTPUT);

Serial.begin(9600);

digitalWrite(relay, HIGH); // motor ON
digitalWrite(greenLED, HIGH);
}

void loop() {

// Ultrasonic distance
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;

int crack1 = digitalRead(ir1);
int crack2 = digitalRead(ir2);

if (distance < 20 || crack1 == LOW || crack2 == LOW) {

digitalWrite(buzzer, HIGH);
digitalWrite(redLED, HIGH);
digitalWrite(greenLED, LOW);
digitalWrite(relay, LOW); // Stop train

Serial.println("ALERT! Track Damage or Obstacle Detected");

} else {
digitalWrite(buzzer, LOW);
digitalWrite(redLED, LOW);
digitalWrite(greenLED, HIGH);
digitalWrite(relay, HIGH); // Train running
}

delay(500);
}

📲 8. GSM Alert Message Example

When fault occurs, system sends SMS like:

ALERT!
Track Crack or Obstacle Detected
Location: Track Section A12

📊 9. Advantages

✔ Prevents railway accidents
✔ Low cost system
✔ Automatic detection
✔ Real-time alert system
✔ Easy to install