Howdy gang. Quick little background: my "day" job is that as a locomotive engineer (or engine driver if you're in other parts of the world). I've had an interest in railroads all my life, passed down from my father.
Years ago, a friend of ours had a controller unit out of a scrapped locomotive he wanted to turn into a throttle for controlling his model trains. As far as I know, he never did anything with it. Fast forward to now, and I find myself in the same position.
A locomotive throttle has a total of 10 positions, STOP, IDLE, and "Notch" or Run" 1-8. There are 6 roller switches inside of the control stand that are activated as you move the throttle around, in different combinations. The locomotive's governor responds to these switches and increases (or decreases) engine RPM's appropriately.
I figure I can hook these 6 switches up to the digital pins, setup as inputs, and have my Uno read their HIGH and LOW states, however, my concern is with the looping code that's required:
The roller switches are NOT push-buttons, so when one is closed, it would be read as LOW - so, if the Arduino keeps getting a LOW result as it goes through the loop, it'll keep sending whatever command, right? Is it possible to code the Arduino to only send a command once, for roughly quarter to half a second?
If that's not clear enough:
Engine throttles normally start in IDLE. When I advance to Run 1, I want the Arduino to send a command for 250ms, then stop commanding until the throttle position is changed again while still checking the states of the switches. I figure it will probably need an integer value to reference what position I'm in and maybe a sneaky one to have it only run the output command once? My C skills are old - I haven't messed with it much since senior year in high school (15 years ago).
I haven't worked out how I will get the Arduino to interface with my Digital Command Control system (yet) but the manufacturer of it is generally friendly to the users, so I hope they will be able to assist me, but I want to get this sorted first. One step at a time.....
I'll be happy to answer any questions that you guys may have, and thank you in advance for looking over my post.