• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Circuit Ideas for You

Get free circuit ideas online.

  • Home
  • Privacy Policy
  • About
Home » Railway Track Accident Prevention Circuit using Arduino

Railway Track Accident Prevention Circuit using Arduino

Last updated on 18 November 2025 by Admin-Lavi Leave a Comment

Railway accidents happen because obstacles come on railway track.

Many trains cannot stop fast.

This project uses Arduino Uno, ultrasonic sensor, relay and motor or servo to give warning or stop mechanism.

The system checks distance.

If object comes close, relay activates and motor moves barrier or alarm system.

This helps to avoid accidents in simple low-cost way.

This Railway Track Accident Prevention Circuit using Arduino is easy to build.

Arduino Coding:

const int trigPin = 9;
const int echoPin = 10;
const int relayPin = 7;
const int servoPin = 6;

long duration;
int distance;

#include <Servo.h>
Servo myservo;

void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(relayPin, OUTPUT);
myservo.attach(servoPin);
myservo.write(0);
digitalWrite(relayPin, LOW);
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.println(distance);

if (distance < 20) {
digitalWrite(relayPin, HIGH);
myservo.write(90);
} else {
digitalWrite(relayPin, LOW);
myservo.write(0);
}
delay(200);
}

Coding Explanation:

  • Ultrasonic sensor sends sound pulse.
  • Echo pin reads back the signal time.
  • Arduino calculates distance from time.
  • If distance is less than set value like 20 cm then Arduino turns relay ON.
  • Servo also rotates to show barrier movement.
  • If distance is safe then relay stays OFF and servo goes back.
  • Simple logic control.

Circuit Working:

Railway Track Accident Prevention Circuit Diagram using Arduino

Parts List:

ItemQuantity
Arduino Uno1
Ultrasonic Sensor HC-SR041
5V Relay Module1
Servo Motor (SG90)1
DC Motor1

Arduino gives 5V power to ultrasonic sensor and to servo.

Trig pin sends pulse.

Echo pin reads reflection.

Relay module gets 5V and signal from Arduino digital pin.

Relay can drive a DC motor or alarm.

When object is detected close then relay activates and motor or alarm starts.

The servo rotates to show gate closing.

All devices share common ground.

Formulas:

Ultrasonic distance formula:

Distance = (time x speed of sound) / 2

Speed of sound in air approx 340 meter per second

In microseconds speed about 0.034 cm per microsecond

So distance = duration x 0.034 / 2

Division by 2 because pulse travels to object and back.

How to Build:

To build a Railway Track Accident Prevention Circuit using Arduino follow the below steps:

  • Gather all the parts as shown in circuit diagram.
  • Ultrasonic sensor VCC pin go to 5V.
  • GND pin go to GND.
  • Trig pin go to Arduino pin 9.
  • Echo pin go to Arduino pin 10.
  • Relay module VCC pin go to 5V.
  • GND pin go to GND.
  • Signal IN pin go to Arduino pin 7.
  • COM pin goes to +5V of Arduino
  • Relay output terminals go to motor.
  • Servo motor Red wire go to 5V.
  • Brown wire go to GND.
  • Orange or yellow wire go to Arduino pin 6.
  • One wire of the DC motor goes to relay NO (Normally Open) terminal.
  • And other end must be connected to Arduino GND.

Conclusion:

This project for Railway Track Accident Prevention Circuit using Arduino gives simple method to avoid railway accidents.

System detects object on track using ultrasonic sensor.

Arduino controls relay and servo to give warning or close barrier.

Cost is low and working is stable.

It can be installed on small rail crossings or demo models.

It increases safety and reduces human error.

References:

Prevention of Railway Accident using Arduino Based Safety System: A case Study of Addis Ababa Light Rail Transit

Filed Under: Arduino Projects, Sensors and Detectors

About Admin-Lavi

Lavi is a B.Tech electronics engineer with a passion for designing new electronic circuits. Do you have questions regarding the circuit diagrams presented on this blog? Feel free to comment and solve your queries with quick replies

Previous Post: « Arduino Based Pulse Monitoring Circuit
Next Post: Rain Detector Circuit using Arduino »

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar




Categories

  • Alarm Circuits (39)
  • Amplifier Circuits (67)
  • Arduino Projects (77)
  • Audio Circuits (103)
  • Automobile Circuits (19)
  • Battery Charger Circuits (54)
  • Free Energy (13)
  • Heater and Temperature Controllers (13)
  • High Voltage (1)
  • Indicator Circuits (44)
  • Inverter Circuits (16)
  • IoT projects (1)
  • LDR Circuits (24)
  • LED and Lamps (135)
  • Meters and Testers (30)
  • Motor Controllers (19)
  • Oscillator Circuits (35)
  • Power Supply Circuits (94)
  • Remote Control Circuits (10)
  • Security and Protection (26)
  • Sensors and Detectors (112)
  • Solar Circuits (23)
  • Timer Circuits (35)
  • Transistor Circuits (68)
  • Transmitter Circuit (16)
  • Tutorials (8)
  • Water Level Controller (4)

Recent Posts

  • 555 Timer Astable Multivibrator Circuit
  • 555 Timer Monostable Multivibrator Circuit
  • Rain Detector Circuit using Arduino
  • Railway Track Accident Prevention Circuit using Arduino
  • Arduino Based Pulse Monitoring Circuit

Recent Comments

  1. Henrik Arboe Jensen on Adjustable Voltage, Current Power Supply Circuit using Transistor 2N3055
  2. Admin-Lavi on FM Transmitter Circuit (100 meters range)
  3. DEVINDER SINGH on FM Transmitter Circuit (100 meters range)
  4. Admin-Lavi on Constant Voltage, Constant Current Battery Charger Circuit
  5. Bill on Constant Voltage, Constant Current Battery Charger Circuit

Copyright © 2025 | New Circuit Ideas