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:
- A pair to connect the turnout to the motor driver.
- Second pair to connect the power of the outer track to the motor driver.
- 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!