I have to read a single digital input signal (a trivial open/closed-circuit push button) and use this signal in an Android application on a smartphone.
Of course, I could connect a tiny Arduino-like board to the USB port of the smartphone, use the digital input pins of this board to read the electrical signal and pass a message to the Android app but this task is so simple that I would like to avoid the use of any addictional board.
So, I wonder if it would be possible to (ab)use a regular headset wire for this task.
I would like to connect a regular 3.5mm headset to the smartphone, cut away the actual speakers and microphone, connect two of the resulting free wires to my push button and read the open/closed-status change of the switch from my app.
As long as I can see, Android has a ACTION_HEADSET_PLUG intent and a AudioManager.isWiredHeadsetOn() function so this is probably possible.
Does anybody have any idea about the correct wiring I should use? In particular, should I insert a resistor/capacitor to protect the inner circuitry of the audio board?
Any suggestion about the software side?
Please note that I'm only interested in reading the change of the switch status from open to closed or viceversa. I do not need to know the current status of the switch.
PS: No, I'm not willing to destroy the smartphone and connect the external push button to the existing keyboard.