Simple Automated Point to Point Model Railroad

929

5

2

Arduino microcontrollers are great to automate model railroad layouts. Automating layouts is useful for many purposes like putting your layout up at a display where the layout operation can be programmed to run trains in an automated sequence. The low cost and open source Arduino microcontrollers and the widespread community make it easy and simple to make projects and program them.

So, without further ado, let's get started!

Step 1: Watch the Video

Watching the video can help you get a fair idea of how this works.

Step 2: Get the Parts and Components

Here is what you will need:

  • An Arduino microcontroller board.
  • An L298N motor driver module.
  • 2 'sensored' tracks.
  • 6 male to female jumper wires(A set of 3 wires each to connect the sensors pins to the Arduino board's digital I/O pins and power.)
  • 3 male to female jumper wires(To connect the motor driver's input pins to the Arduino board's digital I/O pins.)
  • 2 male to male jumper wires(To connect the motor driver to power and ground connection.)
  • 2 male to male jumper wires(To connect the motor driver's output terminals to power the track rails.)
  • A 12-volt power supply(Current capacity should be at least 1000mA or 1A for N-scale.)

Step 3: Program the Arduino Microcontroller

Get the Arduino IDE from here. You may need to make some adjustments to the Arduino code for your layout.

Step 4: Make a Test Layout

Click on the above picture to get more information.

Make a layout with bumper tracks at each end. The length of the mainline track between the stations can be made as long as required. Since the train slows down after crossing the 'sensored' track and continues to move for some distance, make sure there is a sufficient length of track between the 'sensored' tracks of each points A and B and their bumper tracks. The above picture might be useful for a reference.

Step 5: Make Wiring Connections for the Motor Driver

Make the following wiring connections:

  • Connect the motor driver's input pin 'IN3' to the Arduino board's digital output pin 'D8'.
  • Connect the motor driver's input pin 'IN4' to the Arduino board's digital output pin 'D9'.
  • Connect the motor driver's input pin 'ENB' to the Arduino board's digital output pin 'D10'.

Connect two male to male jumper wires to the terminals marked 'GND' and '+12-V' and connect them to the pins marked 'GND' and 'VIN' of the Arduino board respectively.

Connect two male to male jumper wires to the output terminals of the motor driver and connect them to the track rails through a power feeder track.

Step 6: Wire Up the Sensors to the Arduino Board

Connect both the sensors' 'VCC' and 'GND' pins of the sensors to the '+5-volt' and 'GND' pin of the Arduino board. You might need to get a bit creative to connect two 'VCC' connection jumpers to a single '5-volt' pin available on the Arduino UNO. Connect the 'OUT' pin of the sensor of station 'A' to the Arduino board's pin A0 and the remaining sensor's pin to the Arduino board's pin A1.

Step 7: Place a Test Locomotive on the Tracks

For testing purposes, place any locomotive or a powered car on the point 'A' of the layout from where the locomotive or the powered car will start.

Step 8: Connect the Setup to Power Source and Power It Up

Connect the Arduino board's power input connector to a 12-volt power source and turn it on.

Step 9: Watch Your Train Operate Autonomously

If everything was done correctly, you should see your test locomotive or powered car start from point 'A', speed up after crossing the first 'sensored' track it approaches, slow down and stop at point 'B' after crossing the second 'sensored' track, start again after a few seconds in the opposite direction, speed up after crossing the first 'sensored' track it approaches, and slow down and stop at point A after crossing the 'sensored' track installed near point 'A'. It will wait for a few seconds before starting the entire process again.

If the locomotive starts to move in the wrong direction, interchange the wires connected to the track power from the output of the motor driver.

Step 10: What's Next

Try tweaking the Arduino code to run the trains as per your wish, try adding more functions to the layout by combining my previous projects with this one. Whatever you do, all the best!

Arduino Contest 2019

This is an entry in the
Arduino Contest 2019

Share

    Recommendations

    • Arduino Contest 2019

      Arduino Contest 2019
    • Tape Contest

      Tape Contest
    • Trash to Treasure

      Trash to Treasure

    2 Discussions