Kushagra Keshari

lroad(1).JPG 

 

A while back, I came across this video on YouTube:

 

 

Then I thought, why not use this to control a model railway?!

 

I got the PS/2 keyboard library for Arduino from here. Since I still didn't had any PS/2 keyboard, I went out and bought a used one from a computer repair shop.

After a few minutes of fiddling with wires and tinkering with the Arduino code, I got it working.

Controlling a model railroad

For communicating with a PS/2 keyboard, I used an Arduino UNO microcontroller and used the Arduino IDE to program it. For driving the locomotive and the solenoid-based turnouts, I used an Adafruit Motor Shield V2. It used only two digital I/O pins of an Arduino board which leaves plenty of room to connect other modules and devices to the board, including a PS/2 keyboard.

Locomotive control

IMG_1674.JPG 

For controlling the track power for the locomotive, I used a variable in the code for storing the speed of the locomotive, ranging from -255 to 255 where -ve numbers make the locomotive move backward. I mapped the up and down arrow keys to increase and decrease the value of the variable in the range(-255 to 255). 

Turnout control

IMG_2159.JPG 

I've used two turnouts whose controls had been mapped to the number keys. 1&2 for first turnout and 3&4 for the second one.

You can find full documentation and the source code for this project here.

I hope you will enjoy making this project. Try tinkering with the code and add more features.

All the best!

Reply 0
Photo Bud

Interesting.

I noticed you've gotten a lot of reads, but no comments. This is one of the reasons I favor reaction capability on forums as they allow positive (or negative) feedback.

This project has some great potential and appreciate your time and effort in presenting it. I could see it being used to also control scenic automation effects.

Bud (aka John), The Old Curmudgeon

Fan of Northern Pacific and the Rock Island

Reply 0
Kushagra Keshari

Thank you

I am glad to know you liked the project.

Reply 0
jeffshultz

Interesting indeed

At first I thought this was a DCC++ hack, but I see it is straight DC control. I can see a use for it on a pure display layout, where a full control system wouldn't be needed.

orange70.jpg
Jeff Shultz - MRH Technical Assistant
DCC Features Matrix/My blog index
Modeling a fictional GWI shortline combining three separate areas into one freelance-ish railroad.

Reply 0
jimfitch

Interesting exercise but I've

Interesting exercise but I've always preferred a rotary knob to control my train forward and reverse speed.

.

Jim Fitch
northern VA

Reply 0
Reply