Response to Austrains' announcement of a C30 tank and C30T
An Announcement from Austrains - SDS acquisition
Connecting loco and tender - Hornby Top Tips
Trainorama 830 class 847 review
Under the Portuguese Sun - Tree planting
Bachmann new GWR Earl Class review
Reconnecting with a childhood hobby
James May urges nation to 'save Hornby' as shares plunge 62%
Hornby boss quits after third profit warning in five months
Statement from Ixion Model Railways Ltd
A while back, I came across this video on YouTube:
Then it hit me. Why not use the same thing to control other stuff?!
Since, I didn't have access to any old, broken laptop, I went to a local computer repair shop and got a Synaptics' PS/2 touchpad for about $1.4. I quickly searched the pinout for the part number of the touchpad and soldered wires to the appropriate pads present on the circuit board.
I connected it to an Arduino microcontroller and uploaded a test code on the microcontroller including the ps2 library(Which can be found here). After a couple of trial and error, it was up and running.
I proceeded to add a stepper motor and programmed the Arduino microcontroller to make the stepper motor follow the finger being slid on the touchpad and it worked great.
The touchpad has two axes, 'X' and 'Y' where the finger can be moved. In the above project, the 'X' axis was being used.
Controlling a Model Railroad [img]https://model-railroad-hobbyist.com/sites/model-railroad-hobbyist.com/files/resize/users/Kushagra%20Keshari/IMG_2162-600x450.JPG[/img]
Controlling the speed and direction of the locomotive was quite easy. The motor shield use in the project can control a DC motor's speed via PWM depending on the number put in the function which ranges from 0 to 255. I programmed the microcontroller with an extra function to accept values ranging from -255 to 255 where the -ve value would make the locomotive go backward and the +ve value would make it go forward. I added a variable (Say 's') for storing that value. Sliding the finger along the 'X'-axis on the touchpad would either add to or subtract some amount from the value stored in the variable, depending on the direction of movement of the finger.
But controlling the turnouts was a bit more challenging. I still had the 'Y' axis free so I mapped one turnout to the 'Y'-axis movement of the finger. But it was not enough.
I further experimented with mapping the two diagonal movements of the finger for two more turnouts and after some testing, changing some numbers and scratching my head, the other two turnouts worked without any problem.
So now we can control three turnouts and a locomotive using a single touchpad. Not bad for a small layout.
Stopping the locomotiveNext, it was time to add a function to stop the locomotive in a simpler way. There was a variable, using which, one could determine whether a finger was slid on the touchpad or tapped on it. Using it, I created a function that would slow down the locomotive moving in either direction and bring it to a halt.
You can find the complete documentation of this project here. All the best for the project build!
I hope you enjoyed this project. If you have any doubts, suggestions, or feedback, be sure to let me know in the comments below.
This article first appeared on model-railroad-hobbyist.com
About this website
Railpage version 3.10.0.0037
All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest is © 2003-2020 Interactive Omnimedia Pty Ltd.
You can syndicate our news using one of the RSS feeds.