Automated Train Reverse Loop Using Arduino

3,303

12

2

About: I am an electronics and model railway hobbyist.

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!

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.

  • A 'sensored' track.
  • 3 female to female jumper wires(to connect the sensor to the Arduino board).

Step 2: Program 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 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 Layout

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 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.

Step 8: Power Up the System

Power up the Arduino board and the motor driver by connecting either the VIN and GND pin respectively to 12-volt power and ground respectively or by connecting the barrel connector of the adapter to the power socket of the Arduino board. Double-check all of the wiring connections and turn on the power.

Step 9: Watch It Working!

If everything goes on well, then your setup should work like the one shown in the above video.

Step 10: What's Next?

Now that you have got the example setup running, you can further add another reverse loop on the other end of the outer track to make the train go running in both the directions on a single track without any interruption(you will need to modify the Arduino program for that). Show off your skills by modifying the Arduino program to increase the functionality of this project or just simply let me know what you did with this. Let me know if you made this project to help me know if this was useful to you at all.

I wish you happy railroading. All the best!

Big and Small Contest

This is an entry in the
Big and Small Contest

Share

    Recommendations

    • Big and Small Contest

      Big and Small Contest
    • PCB Contest

      PCB Contest
    • First Time Author

      First Time Author

    2 Discussions

    1
    None
    raphan

    20 days ago

    Here the Arduino is a bit overwhelming, a simple relay can make the job. But an Arduino permits a lot of functions that add original features to a setup.

    1 reply
    0
    None
    KushagraK7raphan

    Reply 19 days ago

    Thanks for your feedback! The main purpose of using an Arduino microcontroller was to automate the layout to let all the stuff happen without any human interference. This can prove to be very useful when a layout needs to be put up at a display where you cannot be always present to keep a control on trains and turnout switches, also, fully automated model train layouts look quite impressive.