This document describes an automatic gate control system for railway crossings using a PIC controller and 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 when the track is clear on both sides, the gate will open. This system aims to prevent accidents at unmanned crossings by automatically controlling the gate operation based on train detection. 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.