Electronic – Sending data through the iphone headphone jack

buttoniphone

I recently bought a TRRS Pigtail on sparkfun and I want to have two buttons attached to one end of the cord and another end connected to the iphone in the headphone jack. I would like to be able to have an app detect when a button is pressed.

How would I be able to do that?

Best Answer

Generic:

Connect each button between one of the stereo output channels and the microphone input, along with some resistors for attenuation and possibly a capacitor for DC blocking (suitable audio input circuits have been published, you can search for them as readily as I can).

Have your app output an audio tone of different frequency on each of the left and right channels. Have it collect data from the microphone and use one of the known frequency detection algorithms to determine if either or both tone is present at meaningful amplitude.

Vendor Specific:

Research how function buttons on headsets (pause, track skip, whatever) are implemented, and construct such circuitry. Act like a playback app that could use these, register with the operating system for those events, and do what you want with them instead.