In this project, the idea was to control the railway gate and closed the gates early in order to pass the train safely without any uncertainty. I have used four IR sensors in a manner such that When the train comes in front of sensor 1. The Sensor quickly sends the command to the microcontroller which closed the gate and turns ON Red Led to indicate that the train is coming. When the train successfully passes the gate and reached in front of sensor 2. The sensor 2 detects and sends the command to the Microcontroller in order to open the gate and turns ON Green Led to indicate the traffic to start moving safely. The whole programming is performed in C language structure by using Arduino board.