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

by KushagraK7 in Circuits > Arduino

2508 Views, 11 Favorites, 0 Comments

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

IMG_1290.JPG

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.

Watch the Video

Keyboard controlled model train V2.0 | Arduino based | PS/2 interface

Get All the Required Stuff

IMG_1342.JPG

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.)

Program the Arduino Microcontroller

Capture.PNG

Identify the Pins of the PS/2 Connector

td_libs_PS2Keyboard_pins.jpg
IMG_1343.JPG

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.

Connect the Motor Driver to the Arduino Board

IMG_1344.JPG

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.

Connect the PS/2 Connector to the Arduino Board

IMG_1345.JPG

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.

Set Up a Test Layout

IMG_1346.JPG

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

Connect the Motor Driver's Outputs to the Track Power Feeder

IMG_1347.JPG
IMG_1349.JPG

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

Connect the Keyboard to the PS/2 Connector

IMG_1350.JPG
IMG_1351.JPG

Place the Locomotive on the Tracks

IMG_1352.JPG

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

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

IMG_1353.JPG

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.

Sit Back With You Keyboard and Run Your Train

Keyboard controlled model train | Arduino based | PS/2 interface

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!