I bought a small Arduino clone, a Pololu A-Star 32U4 Micro, to handle the button presses, sense the plunger movements and read the accellerometer that will sense the cabinet being pushed. It was 99 SEK (€ 11).
It will appear to the computer as a USB keyboard and joystick.
To sense the plunger positions, I bought a Sharp GP2Y0A41SK0F IR distance sensor for 105 SEK (€ 11). It has an analog output.
I got an ADXL345 accelerometer from E-bay for €5.12. It uses SPI. It needs resistor dividers to level shift the 5V of the microcontroller to the 3.3V of the accelerometer.
I used the built-in pull-up resistors of the 32u4 chip for the switches, so I tied one pole of all the buttons (start, exit, right flipper, left flipper) to ground, and the other to an microcontroller pin.
The plunger distance and accelerometer signals are presented to the PC as joystick inputs on axes Z and X and Y respectively. In order to do this I used a very useful Arduino HID project.
The IR sensor signal is quite noisy, but with some software filtering I think I have gotten it to work reasonably well.
The source code is in my GitHub repository.
I mounted the various components on a stripboard. The green board is the microcontroller, and the blue board is the accelerometer. The buttons are connected to the screw terminals. Some of the voltage divider resistors are underneath the accelerometer board.
This ended up being quite an inexpensive solution. There are commercial solutions, such as the VirtuaPin™ Digital Plunger Kit v2, but it is $160 which is much more expensive than my solution.
In the future, an idea I have is to control the volume by connecting a rotary encoder to the microcontroller, and have the microcontroller send volume up and volume down media control keys to the PC. This way the volume should be controllable in the same way regardless of whether the headphone output or speakers are used.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.