Summary of Automatic Railway Gate for Unmanned Railway Crossing
This project develops an automatic railway gate system to prevent accidents at unmanned crossings in India. Using an Arduino Uno and ultrasonic sensors, the system detects approaching trains and triggers a motorized gate to close via an L293D driver. The design includes safety alerts with a buzzer and LED indicators, with future plans for solar power integration to create an eco-friendly, low-cost solution that saves lives.
Parts used in Automatic Railway Gate for Unmanned Railway Crossing:
- Wood
- Thermocol
- Train and Track (Simulation)
- IC L293D
- IR Sensor set
- Arduino Uno
- DC Motor
- GSM Module
- Solar Panel
- Bread Board
- Wires and Power supply
- Ultrasonic sensor
- Buzzer
- LEDs
The aim of this project is to save lives of people who are crossing unmanned railway crossings; by providing an automatic railway gate solution. There are many accidents occurred and lives are lost while crossing the unmanned railway crossings in India.
Materials Used:
- Wood
- Thermocol
- Train and Track,
Electronic components:
- IC L293D
- IR Sensor set
- Arduino Uno
- DC Motor
- GSM Module
- Solar Panel (Next phase of project)
- Bread Board, wires and Power supply
Circuit operation
Arduino gives a pulse to the ultrasonic sensor. The ultrasonic sensor has a transmit eye and a receive eye. When the Arduino gives a pulse to ultrasonic sensor, the transmit eye transmits an ultrasonic wave. When the train arrives, the ultrasonic wave bounces back. Then the receive eye receives the ultrasonic wave. It gives signal to the arduino; which calculates the distance.
The formula to calculate the distance is to multiply the speed of sound with the time taken for the ultrasonic wave to bounce back and dividing the answer by two.
Then the L293D and the buzzer gets signal from the Arduino and it gives output to the motor. And then Railway gate falls/closes. After the train crosses, the gate goes up/opens. The Motor for Railway gate can also be powered from Solar Panel.

Applications & Benefits
If installed in unmanned railway crossings, it prevents accidents and saves lives.
- Saving lives of people
- Eco friendly solution.
- Low cost
- Can be easily installed
Program
//pin which triggers ultrasonic sound
const int pingPin = 13;
//pin which delivers time to receive echo using pulseIn()
int inPin = 12;
//range in cm which is considered safe to enter, anything
//coming within less than 5 cm triggers red LED
int safeZone = 5;
//LED pin numbers
int right = 5;
int left = 2;
int buzzer =10;
void setup() {
// initialize serial communication
Serial.begin(9600);
}
void loop()
{
//raw duration in milliseconds, cm is the
//converted amount into a distance
Int duration, cm;
//initializing the pin states
pinMode(pingPin, OUTPUT);
pinMode(right, OUTPUT);
pinMode(left, OUTPUT)
pinMode(buzzer, OUTPUT);h
// SETTING TO LOW
digitalWrite(left, LOW);
digitalWrite(right, LOW);
//sending the signal, starting with LOW for a clean signal
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin, LOW);
//setting up the input pin, and receiving the duration in
//microseconds for the sound to bounce off the object infront
pinMode(inPin, INPUT);
duration = pulseIn(inPin, HIGH);
// convert the time into a distance
cm = microsecondsToCentimeters(duration);
//printing the current readings to ther serial display
Serial.print(cm);
Serial.print(“cm”);
Serial.println();
//checking if anything is within the safe
digitalWrite(buzzer, HIGH);
digitalWrite(left, HIGH);
delay(3000);
digitalWrite(left, LOW);
delay(3000);
digitalWrite(right, HIGH);
delay(3000);
digitalWrite(right, LOW);
digitalWrite(buzzer, LOW);
}
}//void loop ends
int microsecondsToCentimeters(int microseconds)
{
// The speed of sound is 340 m/s or 29 microseconds per centimeter.
// The ping travels out and back, so to find the distance of the
// object we take half of the distance travelled.
return microseconds / 29 / 2;
}
Read More Detail :Automatic Railway Gate for Unmanned Railway Crossing
-
What is the main aim of this project?
The aim is to save lives by providing an automatic railway gate solution for unmanned crossings. -
How does the system detect an approaching train?
The Arduino sends a pulse to the ultrasonic sensor, which bounces off the train and returns a signal to calculate distance. -
Which component controls the DC motor for the gate?
The IC L293D receives signals from the Arduino to drive the motor that closes or opens the gate. -
What formula is used to calculate the distance of the train?
The system multiplies the speed of sound by the time taken for the wave to bounce back and divides the result by two. -
Can the railway gate motor be powered by renewable energy?
Yes, the motor can be powered from a Solar Panel as part of the next phase of the project. -
What are the key benefits of installing this system?
The benefits include saving lives, being an eco-friendly solution, low cost, and easy installation. -
Does the code use IR sensors for detection?
While IR sensor sets are listed in materials, the described circuit operation specifically uses an ultrasonic sensor for detection. -
What happens when the train crosses the crossing?
After the train crosses, the motor activates again to raise or open the railway gate.


