In one of my previous Instructable, I showed you how you can control your model train with your TV remote. In this Instructable, I will show you how to control a model train layout with a keyboard through a computer using Processing. So, let's get started!
Step 1: Get All the Stuff!
So, before starting with the build, make sure you have all of these;
Any Arduino board compatible with Adafruit motor driver shield
An Adafruit motor driver shield
A crosshead screwdriver
3 pairs of male to male jumper wires(2 pairs for the turnouts and the third one for the power feeder track)
A power feeder track
2 turnout tracks(you can add as many as you want by modifying the Arduino and processing codes)
A 12 volt DC power supply
A suitable USB cable to connect your Arduino board to a computer
An external keyboard (Optional)
Step 2: Get the Arduino Code and Upload It to Your Board
Make sure you have the Adafruit motor shield library installed in your computer.
Step 3: Plug on the Motor Driver Shield to Your Board
Step 4: Connect the Jumper Wires to the Motor Driver Shield
Step 5: Set Up Your Train Layout
Get your tracks and set up your model railway layout.
Step 6: Set Up Your PC
Step 7: Connect the Power Feeder Track and the Turnout Switches to the Motor Driver Shield
Step 8: Set Up the Locomotive and Rolling Stock on the Tracks
Step 9: Connect the Arduino Board to Power
Wait! before powering up your setup make sure there are no loose connections, faulty components and derailed rolling stock or locomotive(s).
Step 10: Connect the Arduino Board to the PC Via USB
Step 11: Launch the Processing 3 IDE and Open the Code
Download the Processing IDE from here. Download the given code and open it in the IDE.
Step 12: Test Your Layout
Feel free to add more features to this layout by altering the codes, adding more turnouts and motor drivers. It's all up to you. I hope you will enjoy making this project. All the best for your build!