How can I see if volume buttons of Apple earphones are pressed? 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?
Here is an article that explains the inner working of the Apple headphones:

http://tinymicros.com/wiki/Apple_iPod_Remote_Protocol