Continued from part 1
Dealing with physics
My original plan of simply reading the leads via an analog pin fell apart once I closed up the unit and retested. The values became sporadic and unreliable. The solution is to treat the original board as a pushbutton.
- plug a 2k resistor into 5v
- from the other end of the resistor, run one lead to both:
- digital pin 2
- a pushbutton lead
- run the other pushbutton lead to ground
The state of the button can now be read via pin 2
Testing the new configuration
I purchased a cheap electronics kit, complete with breadboard, resistors, LEDs, and power source.
When I put everything together in a mock assembly:
- The button responded poorly or not at all
- The Easy Button to made noise (!?)
The source of the noise was a speaker attached to the pcb. I’m not sure why this behavior started, but desoldering it cleared up both issues.
I found an acrylic Arduino case to use as the base. With some modification, It can be attached via two of the bottom screws of the button shell.
Closing it up
The HID-Project library is used in a simple sketch to handle the button debounce and HID output. It could easily be modified to output as a keyboard instead.
Testing it out
In the Game Controllers control panel, the device registers as Arduino Leonardo. Pressing the button controls gamepad button 1.
As mentioned in part 1, the only read-world purpose that I can think of at the moment is to use it as a launch stage binding in Kerbal Space Program. Simple bind it from the main menu. Make sure to unbind space bar in order to eliminate accidental staging (the whole point !)
The final result
Mostly pointless? Yes, but it was an excuse to put an Arduino to work as well as provide an electronics refresher.