There are lots of train groups around. Many of the setups are very realistic including automated crossing gates etc. R2S2 has spend some time developing some smarts that allow an Arduino to control trains so that they can pass each other and not collide.
"This shows an automatic control of two trains on a single track. The fright engine switches in each stop to the other side of the train. The control is programed on a Arduino (ATmega168) (~30$). The electronic amplifying the signals is self-made. The Arduino feeds optocoupler, which in turn power relays and one power transistor. The relays switch the direction of traffic, signals and turnouts. The power transistor is set by a PWM signal and controls the train speed. One self-made reed contact in front of each stop signal the micro controller the arrival of the train. The other distances are time controlled. Since the train speed is temperature dependent, the travel time between the two reed contacts is used for a temperature control. The other trains shown are (currently) controlled manually."