Automatic railway level-crossing gate

Unmanned and poorly manned level crossings have caused many accidents in India. A gate that senses an approaching train, warns road users and closes, then opens after the train passes, shows how crossings can be automated.

Arduino UnoMini projectECE, EEE, Diploma
UNOIR59°Featured
Parts
₹3,172
Build
8 weeks
Board
Arduino Uno
Objectives
5

Block diagram

Inputs
  • IR
    IR sensors before and after the crossingDetect the train on each side
Controller
  • UNO
    Arduino UnoRuns the crossing sequence
Outputs
  • 59°
    Two servo gatesClose the road
  • Flashing lights and buzzerWarn road users
  • 4G
    4G modemSends SMS alerts and calls over the mobile network+

Objectives

  1. To detect a train approaching from either direction.
  2. To flash lights and sound the buzzer, then close the gates after a warning time.
  3. To open the gates only after the train has cleared the far sensor.
  4. To check the sequence works for 20 runs in both directions.
  5. To send SMS alerts through a 4G modem where no Wi-Fi is available.

Parts and specifications

Total about ₹3,172 at typical online prices. Tap a part for its pinout and datasheet notes.

Design calculations

Warning time

Real crossings warn at least 20 to 30 s before the train. In the model, with a train at 0.3 m/s and the far sensor 1.5 m away, warning = 5 s; close gates after 3 s of flashing.

Direction logic

Train from the left trips A1 first: start sequence. Open only after B2 then B1 clear, so the whole train has passed.

Servo speed

Move 1° every 15 ms: 90° in 1.35 s, so the boom lowers smoothly.

Pin map

SignalPin or connection
Sensor A1 / A2 (left side, far and near)D2 / D3
Sensor B1 / B2 (right side)D4 / D5
Gate servosD9 / D10
Red lightsD6, D7 (alternate flash)
Buzzer (via transistor)D8

Firmware outline

  1. IDLE: gates up, lights off.
  2. On A1 or B1, remember the direction and go to WARNING: flash lights and buzz.
  3. After 3 s go to CLOSING: lower both gates slowly.
  4. CLOSED: wait until the far exit sensor sees the train and then clears for 2 s.
  5. OPENING: raise gates, lights off, back to IDLE.
  6. Fail-safe: if a sensor stays blocked over 60 s, keep the gates closed and flash.

Test plan

TestExpected result
Train left to rightFull sequence, gates open after it passes
Train right to leftSame
Toy car under the boom while closingNote the need for an obstacle check
20 runsNo missed trains

These rows start your results table when you plan the project.

Viva practice

Say your answer out loud first, then check. The first 2 answers are free; Maker opens all 5.

1. Why is the system fail-safe?
2. Why sensors on both sides?
3. What do real crossings use?
4. What is a state machine?
5. How would you warn road users further away?

Make it yours

One or two upgrades for a mini project, two to four for a major one.

Build these first

Datasheets and sources to cite

  • Indian Railways Manual for Level Crossings
  • TowerPro SG90 datasheet
  • Microchip ATmega328P datasheet

About this project

How much does the automatic railway level-crossing gate project cost?

About ₹1,582 for the parts in the base list: Arduino Uno R3 (CH340 clone), IR obstacle sensor module × 4, SG90 micro servo × 2, LED 5 mm red with 220 Ω × 4, 12 V piezo alarm, Breadboard 830 points, Model track, toy train and road, 5 V 2 A adapter.

How long does it take?

About 6 weeks for the base project, built on an Arduino Uno. Each upgrade adds time.

Which branches is it suitable for?

Electronics and Communication, Electrical and Electronics, Diploma (any electronics branch), as a mini project.

Which pins and design calculations does it use?

Sensor A1 / A2 (left side, far and near) on D2 / D3; Sensor B1 / B2 (right side) on D4 / D5; Gate servos on D9 / D10. Worked calculations on this page: warning time, direction logic, servo speed.

How do I test it?

Train left to right: Full sequence, gates open after it passes. Train right to left: Same. Toy car under the boom while closing: Note the need for an obstacle check. 20 runs: No missed trains.

What are the objectives?

To detect a train approaching from either direction. To flash lights and sound the buzzer, then close the gates after a warning time. To open the gates only after the train has cleared the far sensor. To check the sequence works for 20 runs in both directions.