The document describes an automatic railway gate control system that uses sensors to detect approaching and departing trains. When a train is detected approaching, the system calculates the time needed for the train to reach the road and then closes the gate/barrier accordingly. Another sensor detects when the train departs and then the gate/barrier is restored to its initial open position. This automatic system aims to avoid human errors and improve efficiency compared to manual railway crossing systems.