Let Arduino act as "game controller" for Train Simulator or similar

Hello you all!I’m a newbbie with Arduino but I love it. I wonder if and how it should be possible to use Arduino to control simulation games such as MS Train Simulator or similar. This game receives commands from keys (or combination of them) from the computer keyboard. I’d like to connect to Arduino buttons and potentiometer and by using appropriate code ask Arduino to convert them into keyboard format and send to a computer Usb port (as it was a secondary keyboard or a joystick).
In commerce there are specialized “controllers” or joystick containing buttons and cursors you can use to play the game, it’s enough to tell the controller configuration which keystroke emulate when pressed. My idea would be to create this controller by using Arduino a code and a custom card with buttons switches and potentiometer.
Does anybody feel it would be possible ? and in case it was, has anybody any suggestion ?

Many thanks in advance !

Best regards


Try this code, it sends a basic command to logoff the computer, SO it may be just what you need to get started. you may need to read the .txt to see what keys you can press for this.

Basically when one of your buttons, pots or switches are activated, it will send the corrsponding button to the computer.

Try it write something in notepad or wordpad.


Thanks a lot for fast reply and for suggestion! I just tried it but it seems keyboard library it works under Leonardo (as this was told me by Arduino development app) and not for Arduino Uno I own. I'll try to understand how to workaround this problem if possible. Grazie - Giorgio

I haven’t done it myself, but Google turned up several descriptions of projects which have successfully done this on a UNO. The term you’re looking for is “HID” (Human Input Device i.e. mouse, joystick or keyboard).