A proximity sensor measures receptor output with an energy source deactivated.
The sensor then measures receptor output with the energy source activated. The
measurements with the energy source activated are compared to the measurements
with the energy source deactivated to compensate for the effect of ambient conditions.
A near condition is recognized if the change between the two groups of measurements
exceeds a designated value. To compensate for receptor output that may decrease
after reaching a peak value during approach of an object, a near condition can
be maintained until the change between the two groups of measurements no longer
exceeds a different designated value. Multiple sensors can be used to avoid false
near conditions caused by, e.g., placing a device equipped with the sensors next
to a stationary object. In one embodiment, a sensor comprises an infrared light
emitting diode and a phototransistor.