The railway crossing is now updated (Arduino Uno, MG90S servo motors) and integrated into a control system running on a PC. The barriers start closing when the train is 250 cm from the crossing or when the train leaves the station.
The inspiration came from level crossings in Slovenia.