They don't make light guns that work with LCD screens, so I wrote this to emulate the old arcade light guns for using with a modern PC.
- an Arduino pro micro
- a Gyroscope
- an Accelerometer
- Rotary encoder
- Analog thumbstick
- Switch
- Two push buttons
- Primary firing
- Secondary firing
- Scope aim
- Reload
- Character leaning (by tilting the gun)
- Adjustable sensitivity on each axis
- Movement (using a mini-joystick/thumbstick)
- Aim hold (press to adjust the gun without moving the crosshair)
- On/off switch
The code is complete and should work for anyone. Take careful note of the pin assignments and adjust accordingly.
There is mini-joystick support for movement and zoom (aiming down sights). I feel like it would be limiting if you have to use a secondary controller/keyboard for movement, but it's your call if you want to use it.
All options are just that, optional. If you don't add a joystick or encoder or buttons they'll just be ignored. No need to disable them in the code.
This code can easily be used as a simple hover-mouse if you wish, with zero required code changes.
- Trigger : Left mouse
- Alt : Middle mouse
- Reload : Presses 'r' key
- Encoder : increase/decrease gyro sensitivity on a per-axis basis (press encoder button to switch axes)
- Encoder + Alt : Re-calibrate gyro
- Encoder button :
- (press) Switch between X and Y gyro sensitivity adjustment
- (hold) Hold cursor - used to adjust gun aim
- Joystick : WASD keys
- Joystick button : Right mouse
- Left/Right tilt : Presses PgUp/PgDn keys (designed to be used for leaning in games which support it)
My code is on Github: https://github.com/Domush/Arduino-Arcade-PC-light-gun
If you wish to use this code for commercial purposes, you must contact me for permission.