This question already has an answer here:
You all know smartphone headsets. Most of them have a microphone integrated and additional pushbuttons for increasing/decreasing the volume or to pause the current track. I am wondering how this is working. The plug has 4 pins. I assume one pin is GND, two are for left and right audio and the fourth is for the microphone. So how are the pushbuttons connected then? There are three pins missing.
Maybe the microphone pin is used as bidrectional pin? If it is so there must be a protocol which declares which button was pressed (like UART). Also I don't know where the power suppy should come from. All the headset gets is an analog audio signal from the master device.