Object detection for train set

I am looking for a Pololu product that will help with object detection. I have a Marklin HO layout (toy trains). I want the product to detect when the train passes, and act as a switch until the train has completely passed the sensor. As the train passes, I want current to be on, when the train has completely passed the sensor, I want current off. Current on will trigger = cool train sounds (ding, ding ding, etc),. Current off = no sound.

Hi.

A Sharp Digital Distance Sensor should work for your application. However, you will probably need some type of MOSFET to get a significant current output. These sensors output a digital low signal when an object is detected, so using a P-channel FET on the output should allow current to flow when the train is sensed.

-Claire