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.
- Parts
- ₹3,172
- Build
- 8 weeks
- Board
- Arduino Uno
- Objectives
- 5
Block diagram
- IR sensors before and after the crossingDetect the train on each side
- Arduino UnoRuns the crossing sequence
- Two servo gatesClose the road
- Flashing lights and buzzerWarn road users
- 4G modemSends SMS alerts and calls over the mobile network+
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.
- To send SMS alerts through a 4G modem where no Wi-Fi is available.
Parts and specifications
- Arduino Uno R3 (CH340 clone)ATmega328P 16 MHz, 32 KB flash, 2 KB SRAM, 5 V logic, 6 analog inputs (10-bit), 6 PWM pins₹450Buy
- IR obstacle sensor moduleReflective IR pair with LM393, 2 to 30 cm set by trimmer, digital out, sunlight can false-trigger₹160Buy
- Model track, toy train and road₹400
- 5 V 2 A adapter₹150
- A7670C 4G LTE module4G Cat-1 with 2G fallback, SMS, calls and data, works with any Indian SIM including Jio; 3.4 to 4.2 V, 2 A peaks₹1,500Buy
- LM2596 buck converter (set to 4.0 V for the modem)4 to 40 V in, 1.25 to 37 V out, up to 2 A continuous (3 A peak), about 85% efficient₹90Buy
Total about ₹3,172 at typical online prices. Tap a part for its pinout and datasheet notes.
Design calculations
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.
Train from the left trips A1 first: start sequence. Open only after B2 then B1 clear, so the whole train has passed.
Move 1° every 15 ms: 90° in 1.35 s, so the boom lowers smoothly.
Pin map
| Signal | Pin or connection |
|---|---|
| Sensor A1 / A2 (left side, far and near) | D2 / D3 |
| Sensor B1 / B2 (right side) | D4 / D5 |
| Gate servos | D9 / D10 |
| Red lights | D6, D7 (alternate flash) |
| Buzzer (via transistor) | D8 |
Firmware outline
- IDLE: gates up, lights off.
- On A1 or B1, remember the direction and go to WARNING: flash lights and buzz.
- After 3 s go to CLOSING: lower both gates slowly.
- CLOSED: wait until the far exit sensor sees the train and then clears for 2 s.
- OPENING: raise gates, lights off, back to IDLE.
- Fail-safe: if a sensor stays blocked over 60 s, keep the gates closed and flash.
Test plan
| Test | Expected result |
|---|---|
| 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 |
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.
Make it yours
One or two upgrades for a mini project, two to four for a major one.
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.
