Keyboard Controlled Model Train V2.0 | PS/2 Interface

882

6

About: I am an electronics and model railway hobbyist.

In one of my previous Instructable, I showed you how to control a model railway layout using a keyboard. It did great but had a drawback of requiring a computer to operate. In this Instructable, let's see how to control a model train using a keyboard through Arduino. So, without further ado, let's get started.

Step 1: Watch the Video

Step 2: Get All the Required Stuff

For this project you will need:

  • An Arduino microcontroller
  • A PS/2 keyboard
  • A female PS/2 connector(Get the one as shown in the picture, it will make your life easier.)
  • An L298N motor driver module
  • A 12-volt DC power source with a current capacity of at least 1A(1000mA).
  • 3 male to female jumper wires(To connect the motor driver's inputs to the Arduino board's output pins.)
  • 4 male to male jumper wires(To connect the motor driver to power and the tracks.)
  • 4 male to male jumper wires(To connect the PS/2 connector to the Arduino board.)

Step 3: Program the Arduino Microcontroller

Step 4: Identify the Pins of the PS/2 Connector

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.

Step 5: Connect the Motor Driver to the Arduino Board

Make the following wiring connections:

  • Connect the input pin 'ENB' to pin 'D10' of the Arduino board.
  • Connect the input pin 'IN4' to pin 'D9' of the Arduino board.
  • Connect the input pin 'IN3' to pin 'D8' of the Arduino board.
  • Connect two male to male jumper wires to the output terminals 3 and 4 to be later connected to the track power feeder.
  • Connect the 'VIN' pin of the motor driver to the 'VIN' pin and the 'GND' pin to the 'GND' pin of the Arduino board respectively.

Make sure no wiring connections are loose.

Step 6: Connect the PS/2 Connector to the Arduino Board

Make the following wiring connections:

  • Connect 'VCC' to the '+5-volt' pin of the Arduino board.
  • Connect 'GND' to the 'GND' pin of the Arduino board.
  • Connect 'CLOCK' to pin 'D2' of the Arduino board.
  • Connect 'DATA' to pin 'D3' of the Arduino board.

Double check the pinout diagram of the PS/2 connector before making connections.

Step 7: Set Up a Test Layout

Make a simple loop of track to test the setup. Make sure the tracks are cleaned properly to prevent the locomotive from stalling.

Step 8: Connect the Motor Driver's Outputs to the Track Power Feeder

Connect the male to male jumper wires to the power feeder track terminals previously connected to the output terminals of the motor driver.

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

Step 10: Place the Locomotive on the Tracks

Place the locomotive on the tracks, aligning the wheels properly with the rails.

Step 11: Connect the Setup to 12-volt Adapter and Power It On

Double-check all of the wiring connections and make sure everything is connected to the right place and no wiring connections are loose. Plug in the power supply adapter and turn it on.

Step 12: Sit Back With You Keyboard and Run Your Train

Step 13: What's Next?!

I would love to see your project below. After completing this project, don't stop here and try adding more functions to the setup. Whatever you do, all the best!

Share

    Recommendations

    • Pie Contest

      Pie Contest
    • Trash to Treasure

      Trash to Treasure
    • Tape Contest

      Tape Contest

    Discussions