Introduction: Keyboard Controlled Model Railway Layout V2.5 | PS/2 Interface

Using Arduino microcontrollers, there are a lot of ways of controlling model railway layouts. A keyboard has a great advantage of having a lot of keys to add a lot of functions. Here let's see how can we start with a simple layout with locomotive and turnout control. This is an upgraded version of one of my previous projects. So, without further ado, let's get started!

Step 1: Watch the Video

Step 2: Get All the Stuff

For this project you will need:

  • An Arduino microcontroller board.
  • An Adafruit motor driver shield V2.
  • A female PS/2 connector(Get the one shown in the picture, it will make work easier.)
  • 4 male to male jumper wires(For connecting the female PS/2 connector to the Arduino board.)
  • 4 male to male jumper wires(2 for each turnout.)
  • 2 male to male jumper wires(For connecting the track power.)
  • 12-volt DC power source with a current capacity of at least 1A(1000 mA).
  • A PS/2 keyboard(USB one will not work!)
  • A suitable USB cable for programming the Arduino board.

Step 3: Program the Arduino Board and Plug on the Shield

Get the library for PS/2 keyboard from here.

To install the library for Adafruit motor shield, goto Sketch>Include library>Manage libraries and search for Adafruit motor shield V2 library, install it and you're good to go.

Step 4: Identify the Pin Connections of the PS/2 Connector and Connect It to the Arduino Board

Using a multimeter set to continuity test and using the given picture as a reference, mark the pinouts of the PS/2 connector/extension cable wires and make the following wiring connections between the PS/2 connector and the Arduino board:

  • Connect the 'CLOCK' wire to pin D2.
  • Connect the 'DATA' wire to pin D3.
  • Connect the 'GND' wire to pin 'GND'.
  • Connect the '+5-volt/VCC' wire to +5-volt pin.

Step 5: Connect Wires to the Motor Output Terminals

Step 6: Set Up a Test Layout

Step 7: Connect the Motor Output Wires to the Turnouts and Track Power

Double-check all the wiring connections and make sure no wiring connections are loose.

Step 8: Connect the Keyboard to the PS/2 Connector

Step 9: Place the Locomotive and Some Rolling Stock on the Tracks

Step 10: Connect to Power and Turn It On

Step 11: Sit Back With Your Keyboard and Operate Your Layout

Step 12: Go Further!

There are a lot of buttons left on the keyboard. Go ahead and try adding more turnouts and functions to your layout. Whatever you do, don't forget to keep trying new stuff!