Tell me more ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I developed a code in DEV C++ which simulates graphically a the actions of a train driver. Basically I control the speed and some other functions of a train from my keyboard.

Now, instead of the keyboard, I want to use a "home made mouse" i.e. digital/analog inputs to control the program.

Read some articles and seem quite difficult.

Can anyone help me with some advice, or point me in a few directions?

share|improve this question
You mean something like this? – Dave Tweed Sep 21 '12 at 19:22

1 Answer

Modifying a keyboard/mouse/game controller is a possibility for many projects of this type.

Or you could use something like an Arduino as an analog/digital input adapter. This would connect to the PC via USB, and generally would like like a serial port to your program. Your program would just monitor the serial port for data, which could be single bytes indicating various events, several byte messages, or even human-readable newline-terminated strings. The later can make debugging a lot simpler if you don't need to move so much data that you would fill up a high speed serial pipe. For example, your data might look something like this:

airbrake 0\n
throttle 10\n
throttle 85\n
whistle 1\n
whistle 0\n

Or for firmware simplicity, it might be something like

digital 3 0\n
analog 2 10\n
analog 2 85\n
digital 4 1\n
digital 4 0\n

Leaving your PC program to map the channels to names based on knowledge of the wiring of your adapter to the physical controls

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.