0

I need to be able to see if the volume controls and the middle button of Apple earphones are pressed.

I am using an Arduino Uno. I was thinking about using the analogRead function.

I tried connecting the ground of the audio jack to the ground of the Arduino, the micro of the audio jack to the analogPin 0 on the left and right of the audio jack to the 3.3 volt output of the Arduino, but the results of the analogRead are not really useful. They are constantly changing.


So guys i have this code that constantly gives a bunch of numbers. They are never constant.

int analogPin = 0;
int ledPinBlue = 8;  
int ledPinRed = 9; 

int val = 0; 
int times = 0;
int clickTimes = 0;

void setup()
{
  pinMode(ledPinBlue, OUTPUT); 
  pinMode(ledPinRed, OUTPUT); 
  times = 0;
  Serial.begin(9600);
}



void loop()
{
  val = analogRead(analogPin);
  if (val == 0) {
times = times + 1;
  }
  else if (!val == 0) {
times = 0;
  }
  if (times == 500) {
times = 0;
digitalWrite(ledPinBlue, HIGH);   // sets the LED on
delay (500);
digitalWrite(ledPinBlue, LOW);    // sets the LED off
Serial.println("Click");
  }
}

When I press the button of the microphone (the middle button) of the apple earphones, the numbers change to a constant 0.

But when I press the volume buttons, nothing seems to change. Any ideas?

This is my connection to the arduino.

4
  • If you can't work out how the Apple ones work, would using Android ones be an option? They are much simpler and the information is public domain.
    – Mark Smith
    Feb 11 '17 at 20:01
  • @MarkSmith android ones are good for me, i did not really know there is a differance between them. But how should I do it with android earphones? Feb 11 '17 at 21:30
  • MAYBE the buttons change greatly the voltage on the mic input.. try to map them; maybe (just a dumb example) the values you read when the button is not pressed vary between 0 and 300, while the button pressed is around 600... or maybe try with an oscilloscope: if the voltage can go below zero maybe you are just losing some data when sampling only positive values..
    – frarugi87
    Feb 12 '17 at 10:17
  • Here is an update. I did some test and i will soon set up a version of something I found while testing. It works with the middle button but not with the volume buttons. Feb 12 '17 at 16:15
1

Here is an article that explains the inner working of the Apple headphones:

http://tinymicros.com/wiki/Apple_iPod_Remote_Protocol

0

Since you say that an Android headset would be an alternative....

Google have published the specs for how headset controls work on Android: in short, (up to) four different values of resistor connected between mic and gnd represent the four buttons.

If you just need to read the controls, use a potential divider between Vcc and ground, and read the mid point with an analogue input to tell you which (if any) key is being pressed.

schematic

simulate this circuit – Schematic created using CircuitLab (Wow, that's big... Dunno how to make it smaller :-) )

2
  • Could you give me a picture of how to connect the pins to the arduino? Sorry, i dont really have much knowledge of electronix. I just know the basics. Feb 12 '17 at 10:10
  • If that schematic doesn't get you started, i I think you're going to struggle to be honest. Is there something in particular about that picture which doesn't make sense which I can explain?
    – Mark Smith
    Feb 12 '17 at 10:18
0

Have you tried searching Apple Earphones Schematic or something similar? You probably won't find a schematic, at least not from Apple, but I did find this discussion of someone's attempt to figure out what the buttons do, on some kind of Apple earphones or other (you didn't say which ones you have). There must be others who have also experimented with this.

6
  • I am looking for so long now. I really cant find anything usefull Feb 11 '17 at 21:31
  • But i must be possible i think, smartphones and such can detect when the buttons are pressed so why shouldnt it work with a arduino ;) Feb 11 '17 at 21:32
  • Wasn't the article I linked to a good starting point?
    – JRobert
    Feb 12 '17 at 1:29
  • Its helpful but they want a button to simulate the controls. I just need to be able to see when the buttons are pressed with an arduino... Feb 12 '17 at 8:39
  • Can you check my answer? Feb 14 '17 at 19:02

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.