The following is a method to allow day and night detection using Infrared/Visible light sensitive phototransistors and a simple LM339 voltage comparator circuit. A phototransistor is mounted between the rails so that it is covered by the train as it passes. A system widely used in model railroading. For daytime operation the room lights would be on and when the train blocks this light the train is detected. However when the room lights are dimmed or turned off for night operation, under normal conditions the phototransistor would go dark and act as if it was covered by a train and give a false detection.