On each track on one side of the crossing there are two light detectors embedded in the track. Why two? One deals with turning the wigwag lights on when a train arrives from one direction and the other deals with turning the lights off after the train has passed going in the other direction.