Using IR for proximity (HSDL 9100)

Helly fellow arduino peeps!

I'm trying to make a simple proximity measurement using the HSDL 9100 on an arduino uno. Im not quite sure how the circuit should look like, but it looks like the schematic on this picture: http://i.stack.imgur.com/8dnSG.png .. Serial print gives 900 and is not affected by the sensor itself. Code is given below:

int readValue;
int pwmPin = 6;

void setup(){
  Serial.begin(9600);
  pinMode(pwmPin, OUTPUT);
  pinMode(A0, INPUT);
}

void loop(){
  analogWrite(pwmPin, 127);
  readValue = analogRead(A0);
  Serial.println(readValue);
  delay(500);
}

What are we doing wrong here? Thank you!

http://playground.arduino.cc/Learning/PhotoResistor
This works the same way

(Also your problem it's because the analog pins have a different range comparing to PWM values, so you need to "convert them", which in this example above they are divided by 4)