I am designing a circut to control the crossing lights and motors for the gates. I have an ideal to use photo sensors on the double main line, but I do not know if the senors should in series or be independent. I am also looking for some help in writing the code.
You'll probably also need sensors to tell when the whole train is clear of the crossing, as trains are of indeterminate length and speed. Also remember that two trains could be crossing at the (nearly) same time, so the gates will have to remain closed until both of them have cleared the crossing.
I would, therefore, use indepedent sensors, not connected in series.Your choice of sensor will somewhat depend on what gauge/scale you are modelling to. It's hard to hide a 1/2 dia. LDR on an N gauge layout