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