book collections email follower instructable user

Step 7: How the Code Works: Detecting a Visible Versus an Obscured LED

After some experimentation, I found that the best way to detect whether a pixel is visible from the sensor was to take pairs of analog readings from the sensor: one reading when the LED is off and another reading when the LED is on. If the sensor cannot see the LED, then the readings will be practically the same; if the sensor can see the LED, the readings will be different.

To increase the sensitivity, I take multiple readings while using the OE (output enable) line to turn the LED on and off. I use two accumulators to sum the readings taken when the LED is off vs when the LED is on. I then compare difference between these two sums against a threshold to determine whether the value exceeds some threshold, giving me a decision on whether the LED is within line of sight from the sensor.