The issue is to change polarity of Toy Train.

Thread Starter


Joined Mar 28, 2020
I have a train on a track that will run on 12 volts. The train will go down the track to the end and stop. Then it will change polarity and go the other way to the opposite end and stop and switch polarity again. This will be repeated until I stop it. The time it takes to go down the track will be under on minute. I was thinking to stop the train at the end of the track with a timer. Any help would be appreciated. Thanks,Ernie


Joined Sep 17, 2013
Welcome to AAC!
Instead of using a timer I'd use a limit switch near each end of the trip to reverse the polarity. The problem with using a timer is that unless the train always took exactly the same time for a trip it would sooner or later crash into the buffers.


Joined Sep 11, 2014
Hi Ernie,

Here's a solution, using a magnetic latch relay and limit switches at the front and the back of the train.


- Nandu
Last edited:


Joined Sep 24, 2015
Driving a model train at speed then simply cutting all power to the motor results in an unnatural appearance of the train stopping. Trains don't suddenly stop.

I don't know how to achieve this off hand. With some thought I could probably come up with something. I said "Something". Didn't say I could come up with the best solution; but here's what I think I would want in a model railroad: The train approaches the final station and slows. When it reaches the station it stops. Pauses, then reverses direction. In this scenario I would need to detect a crossing point (sensor 1). That would begin a voltage drop-off of some rate to simulate slowing as it approaches the station. Then the second sensor to tell the train to stop all together. At that point sensor 2 triggers a timer that allows the (imaginary) passengers to exit and board the train. I'm assuming your other post about reversing a motor is the spawn of this thread. After that time period expires the train begins to slowly move away from the station in the opposite direction. It's voltage should rise consistently, simulating a train accelerating to speed. As mentioned before - trains don't suddenly stop. Neither do they suddenly accelerate. Once you have this affect on one end you need to repeat it for the other end. That's how I would approach the problem.

The problem with using a timer is that unless the train always took exactly the same time for a trip it would sooner or later crash into the buffers.
DC motors seldom run the same exact speed in both directions. What @Alec_t is saying is that if you run the motor one direction for exactly 20 seconds the train would travel so far. When you run it for exactly 20 seconds in the opposite direction the train would travel further or shorter than before. Each time you do this the train would grow closer to one end of the track or the other. Eventually the train would run out of track. And given that you seem to want to apply full power and cut full power - the train isn't going to behave naturally, and when it does reach the end of the line it will crash. And all your little passengers will be filing a law suit for their tiny injuries.


Joined Apr 11, 2010
I am planning on running my N Scale model railroad with an Arduino plus a motor shield. The Arduino also used IR reflective sensors to determine train position. Normally, I use a single pot to control the speed of the train. But I have an input to select automatic operation. In this mode, when the train activates a sensor, it slowly stops. A turnout changes position and the train slowly accelerates and backs into a siding and slowly stops, etc...

So it can be done. What the TS desires is available as a commercial product, but it’s pricey. $50