Model railroads use Digital Command Control (DCC) to control locomotives and accessories. Instead of 0-12v DC on the rails, DCC uses a digital packet stream. This circuit will let you write sketches on the Arduino to decode those packets and take actions based on what you decode.

A couple of resistors, an opto-isolator and a LED...

The 6n137 optoisolator and the LED are configured so that both phases of the DCC signal are used - one to drive the opto and one to confirm that there is a DCC signal present. The 1K resistor keeps the magic smoke inside the LED, and the 10K acts as a pullup for the output signal.

Connect the 2-pin terminal block to your track and pin6 of the opto to the Arduino's D8 pin, which is also the Input Compare interrupt pin.

The SourceForge Embedded Loconet project has example code that can be adapted to read and decode this signal (my next project...)