Weird Readings with DAGU IR COMPOUND EYE (IR SENSORS)

Hello,

I am new to this forum and arduino. I have been testing with the IR COMPOUND EYE from dagu..
Trying to use it as a range detector..

I am aware that the maximum range is 200mm.
But when i compile and run the following code on my arduino UNO.. I get strange readings:

void IReye()//=================================================== Read IR compound eye ================================================
{
  digitalWrite(IRen,HIGH);                                     // turn on IR LEDs to read TOTAL IR LIGHT (ambient + reflected)
  delayMicroseconds(500);                                      // Allow time for phototransistors to respond. (may not be needed)
  leftIRvalue=analogRead(IRleft);                              // TOTAL IR = AMBIENT IR + LED IR REFLECTED FROM OBJECT
  rightIRvalue=analogRead(IRright);                            // TOTAL IR = AMBIENT IR + LED IR REFLECTED FROM OBJECT
  upIRvalue=analogRead(IRup);                                  // TOTAL IR = AMBIENT IR + LED IR REFLECTED FROM OBJECT
  downIRvalue=analogRead(IRdown);                              // TOTAL IR = AMBIENT IR + LED IR REFLECTED FROM OBJECT

  digitalWrite(IRen,LOW);                                      // turn off IR LEDs to read AMBIENT IR LIGHT (IR from indoor lighting and sunlight)
  delayMicroseconds(500);                                      // Allow time for phototransistors to respond. (may not be needed)
  leftIRvalue=leftIRvalue-analogRead(IRleft);                  // REFLECTED IR = TOTAL IR - AMBIENT IR
  rightIRvalue=rightIRvalue-analogRead(IRright);               // REFLECTED IR = TOTAL IR - AMBIENT IR
  upIRvalue=upIRvalue-analogRead(IRup);                        // REFLECTED IR = TOTAL IR - AMBIENT IR
  downIRvalue=downIRvalue-analogRead(IRdown);                  // REFLECTED IR = TOTAL IR - AMBIENT IR

  distance=(leftIRvalue+rightIRvalue+upIRvalue+downIRvalue)/4; // distance of object is average of reflected IR
  Serial.println(distance);
}

The readings i get when the obstacle is close is: 800 - 900
when no obstacle and the EYE is made to face the ceiling - i get it 40-80..

Are these the values that are supposed to appear or is something wrong with the code or my IR SENSOR..

Any help is appreciated..
Thanks in Advance

These are the readings received from the serial communication..

981
980
980
980
980
980
980
980
980
980
980
980
980
979
978
978
976
975
975
974
970
967
751

///////////////// The above are when obstacle was in range of 5 - 15cm////////////////////////////////////////

168
167
169
169
168
169
169
168
169
168
168
168
167
169
169

///////////////////// THE above is when there was no obstacle /////////////////////////////////////////////////

I'm no expert, but in your code you are 'asking' the Aduino to give you a relative brightness level with due compensation for ambient light levels.

The relative distance output needs to be an inverse of this.

As it stands though the readings are correct, close object = high figures, no object = low figures.

In your code "distance" is actually brightness or intensity.

A quick 'fix' would be >>> "Serial.println(1000-distance);" as a last line for your program.