Automated Train Reverse Loop Using Arduino

Required Stuff

Making reverse loops can help in model train layouts to change the direction of trains, which cannot be done with turntables. In this way, you can create single-track layouts with a reverse loop on each end to run trains without any pause or interruption. So, without further ado, let’s get started!

Step 1: Gather All the Required Stuff!Required Stuff

For this project, here is the list of required parts and components:

  • An Arduino microcontroller board, recommended ones are UNO, Leonardo, MEGA.
  • An Adafruit motor driver shield.
  • A 12-volt DC power source(can be a battery or an adapter with a current output capacity of at least 1.5 amp)
  • Six male to male jumper wires:
  1. A pair to connect the turnout to the motor driver.
  2. Second pair to connect the power of the outer track to the motor driver.
  3. Third pair to connect the inner loop to the motor driver.

Step 2: Program the Arduino BoardProgram the Arduino Board

If you don’t have Arduino IDE on your computer, download it from here. The library for the Adafruit motor driver shield can be found here, in case you don’t have it in your IDE. Make sure you install this in your IDE before compiling the program. If you need help installing a library, check this link out.

Step 3: Isolate the Inner Loop TracksIsolate the Inner Loop Tracks

Using 4 insulated rail joiners, isolate the inner loop of track from the outer track. Click on the image for more info.

Step 4: Make the LayoutLayout

I used N-gauge Kato Unitrack to make this layout. You can use any other track as long as everything works properly.

Step 5: Plug the Shield on the Arduino Board and Make the Wiring ConnectionsWiring Connections

Before attaching the motor driver shield, make sure all of the pins are aligned and then push the shield down to attach it firmly to the Arduino board. When keeping the board in an upright position(see the above image) such that the analog input pins are on your side, make the following connections:

  • Connect the turnout wires to the terminal block marked ‘M4’ by connecting the +ve or the red wire to the upper terminal and the -ve or the black wire to the lower terminal.
  • Connect the power wires of the inner section of the loop to the terminal block marked ‘M2’. Connect it anyway for now and change the polarity later if the train or the locomotive moves in the wrong direction inside the loop or just stops.
  • Connect the outer track’s power to the terminal block marked ‘M1’. Do the same later as you will do for the track power in the inner loop.

Step 6: Connect the ‘sensored’ Track to the Arduino Board


Connect the pins of the sensor as follows:

  • VCC to +5-volts pin of the Arduino board.
  • GND to GND pin of the Arduino board.
  • OUT to A0 pin of the Arduino board.


Step 7: Place the Locomotive on the Track

Place the locomotive on the outer section of the track to test the setup.

Read more: Automated Train Reverse Loop Using Arduino


Leave a Comment

Your email address will not be published. Required fields are marked *