我是这个论坛和arduino的新手。我一直在用dagu的IR COMPOUND EYE测试.. 试图将它用作测距探测器..
我知道最大范围是200mm。 但是当我在我的arduino UNO上编译并运行以下代码时......我得到了奇怪的读数:
void IReye() {
digitalWrite(IRleds,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(IRleds,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);
Serial.print("\n");
}
障碍物关闭时的读数是:800 - 900 当没有障碍和眼睛面对天花板 - 我得到它40-80 ..
这些是应该出现的值还是代码或我的IR传感器有问题。
//没有任何障碍的物品(面对天花板) 82.00
82.00
82.00
83.00
82.00
82.00
84.00
86.00
88.00
91.00
94.00
99.00
//手放置4厘米时的值 969.00
969.00
969.00
969.00
970.00
970.00
970.00
970.00
任何帮助表示赞赏.. 在此先感谢