I have a little project where I'm trying to control the music playback (play/pause/next/...) on an Android tablet from a Microchip PIC18F MCU.

The tablet has a TRRS mini-jack interface for sound output (ground/left/right audio) and also mic/buttons input. This interface is mentioned in other questions and well described in the Android Headset specification: enter image description here

Basically, each button is connected in series with a resistance of a known value (or rather within a certain range). When a button is pressed, the corresponding circuit is closed and the phone can detect which button was pressed (presumably through some sort of ADC of the voltage level at MIC input).

Now, I would like to have my MCU simulate the various button press, but I'm not sure on how to proceed... basically I need to create a digitally controlled resistor that can take a set of given resistance values.

At first I thought about outputting specific voltage levels at the MIC input (for instance using a PWM output on the MCU), but I don't think that's a very good/robust approach since I don't exactly know how my tablet detects the button presses and also I would like to avoid making my circuit tablet-specific. Currently, I'm thinking about a solution using the resistors connected in series with some small bipolar transistors used in switching mode and controlled by the MCU that would replace the buttons.

What do you think about this idea? Could it work? Do you have any better idea on how to proceed?

Thanks in advance for you suggestions!

  • 1
    \$\begingroup\$ Why can't each switch, when activated, simply be replaced with a saturated BJT controlled by the micro? \$\endgroup\$ – jonk Jun 3 '17 at 14:40
  • 1
    \$\begingroup\$ I was going to say an FET on each switch, but yes. Depending on the electrical details it may even be possible to use MCU GPIO pins, operating in open collector mode (or only configured as outputs when they are to be driven low) to ground the desired resistors. A digipot would meet the original proposal, but is likely to be more costly and complicated to use. \$\endgroup\$ – Chris Stratton Jun 3 '17 at 15:38
  • \$\begingroup\$ Thanks, for your comments! You are both mentioning the use of transistors (BJT or FET) in saturated mode, that's also what I had in mind (mentioned in my question if you read it thoroughly). I just wanted to find out it there wasn't a better solution. The transistor solution requires 4 transistors + 4 resistors + 4 GPIOs... \$\endgroup\$ – Federico Jun 4 '17 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.