Introduction: Automated Model Railroad Layout With Reverse Loops

In one of my previous Instructables, I showed how to make a Simple Automated Point to Point Model Railroad. One of the main disadvantages of that project was that the train had to move in the reverse direction for going back to the starting point. Running a train in that layout meant that it had to run in reverse with the locomotive at the back. So, in this Instructable, let's learn to make a similar layout with a reverse loop at each end so our train can run in the forward direction all the time. Let's get started!

Step 1: Watch the Video

Watch the above video to get a better understanding of this project.

Step 2: Get All the Required Stuff

For this project, you will need:

  • Electronic supplies:
    • An Arduino microcontroller compatible with the Adafruit Motor Shield V2. (1)
    • An Adafruit Motor Shield V2.
    • 2 'Sensored' tracks.
    • 10 male to male jumper wires.
    • A 12-volt DC power source.
  • Model railroad supplies:
    • 2 turnouts(One for each reverse loop).
    • 3 track feeders(One for mainline and the rest two each for a reverse loop).
    • 4 insulated rail joiners(Get 4 more if the turnout being used don't have a "Power Routing" feature).

1. Any R3 Arduino board such as UNO, Leonardo, and similar ones can be used. Boards like Mega can also be used with a slight modification(Get help here).

Step 3: Program the Arduino Microcontroller

I would recommend to go through the Arduino code to get a deeper understanding of how the code works in making the train run around the layout.

Step 4: Replace the Rail Joiners of the Turnouts

If the turnouts being used have a "Power Routing" feature then only the outermost rails need to be electrically isolated using insulated rail joiners. If the turnouts being used don't have this feature, all 4 rails need to be electrically isolated.

Step 5: Set Up the Layout

The 'sensored' track will be installed at the entrance of each of the reverse loops. The mainline and the two reverse loops each will have a separate feeder track.

Decide which one of the loops will be loop A and B. The loop into which the train will enter first on startup will be loop A and the other will be loop B. So, the turnout in the loop A will be turnout A and on in loop B will be turnout B.

Step 6: Install the Motor Shield on the Arduino Board and Connect the Track Power and Turnouts


Both the turnouts need to be connected in parallel but in opposite polarities so that they always switch in the opposite directions.

  • Connect the turnout A to the motor shield as shown in picture 4.
  • Connect the turnout B to the motor shield as shown in picture 5.

Track feeders:

The track feeders for both the reverse loops need to be connected in parallel with the same polarities so that the train moves in the same direction in both the loops, i.e., entering in from the branched line of the turnout and leaving from the straight side(Watch the video in Step 1 for clarification).

  • Connect the mainline's feeder power wires to the motor shield as shown in picture 5. Make sure the polarity of the connection is such that the train moves into the loop A on startup.
  • Connect the loops' feeders' power wires to the motor shield as shown in picture 6.

Step 7: Connect the Sensors

Connect the sensors' -ve pin to the 'GND' header and the +v pins to the +5-volt header. The 'IQREF' pin of an Arduino board can also be used as a +5-volt connection to power sensors for boards working on a logic voltage level of 5-volts.

Connect the sensor's output pin adjacent to the first reverse loop to the input 'A0' of the Arduino board and the output pin of the sensor adjacent to the second reverse loop to the input pin 'A1' of the Arduino board.

Step 8: Double-check All the Wiring Connections

Make sure all the wiring has been done correctly and no connections are loose.

Step 9: Connect the Setup to Power

You can either connect the Adapter to the Arduino board's female DC jack connector or you can use the terminal block on the motor shield to power up the setup.

Step 10: Place the Train/locomotive on the Mainline

Using a rerailer tool is highly recommended, especially for steam locomotives. Make sure that the wheels of the locomotive and the rolling stock(If using) are properly aligned with the track.

Step 11: Power Up the Setup

Step 12: Watch Your Train Go

After powerup, the turnout in loop A should switch to side and the turnout in loop B should switch to straight. After then, the train/locomotive should start to proceed towards the loop A.

If something goes wrong, power down the setup immediately to prevent the motor drivers from getting fried.

Step 13: Troubleshoot If Required

If particular turnout switches in the wrong way, reverse the polarity of its connection. Do the same for the track power feeders if the train starts to move in the wrong direction.

If the setup resets after a while after startup even when the turnouts are switching correctly, check the polarity of connection of the track feeders of the reverse loops and make sure the current is flowing in the correct direction, reverse the polarity if needed.

Step 14: Go Furthur

After you have got your project working successfully, why not tinker with it? Change the Arduino code to suit your needs, add more features, maybe a passing siding? Or run multiple trains? Whatever you do, all the best!