Model trains are always a fun to have and run. But to control them manually sometimes seems to be a bit boring. So in this instructable, I will show you how you can automate your model railway layout so you can sit back and relax while watching your train run on its own. This can be useful at places where you have to put your layout show and you cannot always be present there to control your trains. So, let's get started!
Step 1: Step 1: Collect All the Stuff!
Before starting, make sure you have all the parts for the build:
An Arduino Mega microcontroller board
An Adafruit motor driver shield(as shown in the picture)
A 16x2 LCD screen
A 10 kOhm potentiometer
A 12v DC wall adapter(recommended max current capacity of 1000mA)
Step 2: The Train!
This is a Tomix EF210 N-scale electric locomotive which I bought from Japan. It comes as a set with two container wagons, check it out here: https://www.amazon.co.jp/gp/product/B00EZIDM6M/ref...
Let's first just get our locomotive. We will add rolling stock at the end.
Step 3: The Arduino Program
Download it from here:
Step 4: Making the Control Unit
I tried to use as less wiring as possible in order to keep the setup clean. If you want the LCD screen to be wired differently, you can change the pin connections in the Arduino program.
Step 5: Make the Layout!
I made this test layout to run my train using Kato Unitrack, it is one of the best quality model railway tracks I found in the market. You can make your loop as long or short as possible.
Step 6: Install the Train Controller.
I used a sturdy cardboard box with some weights inside it as a platform for the train controller since it also featured an LCD screen. I used two flat-head screws at the rear part to anchor a plastic fiber ruler to support the controller board standing on the platform.
Step 7: Connect the Power Feeder Track's Wires to the Motor Output of the Driver
Remember those header pins which were connected to the motor output? The feeder track's connector can be attached to these long header pins or you can cut away the connector and connect the track's power through bare-end wires.
Step 8: Put the Locomotive on the Track.
Step 9: Connect 12v DC Power to the Arduino Board and Turn on the Power
Step 10: Check If the Setup Is Working Properly.
The LCD screen should light up and the locomotive should start moving after 5 seconds of powering up the controller. Watch out for loose connections, short circuits, and malfunctioning components. Make sure the rails are cleaned properly to ensure proper electrical contact between the wheels of the locomotive and the rails.
Step 11: Attach Rolling Stock to the Locomotive
Since the locomotive is working perfectly well, let's attach some rolling stock to the locomotive to make it look like a train.