This document describes an automatic gate control system for railway crossings using a PIC controller, IR transmitters and receivers. The IR sensors placed on either side of the tracks will detect approaching trains and send signals to the PIC controller to open or close the gate as needed. When a train is detected, the gate will close, and once the train has passed the other sensor, the gate will reopen. This system aims to prevent accidents at unmanned crossings by automating the gate operation based on train detection rather than relying on human operators. It provides accurate positioning and reduces lead times and manual work compared to traditional methods. The main disadvantage is higher maintenance costs for the electronic components.