Following this discussion
on Lugnet, I built this proof of concept of a light barrier
using NXT light sensor and an optic fiber. Any small object
passing between the end of the fiber and light sensor phototransistor
can be easily detected, even if they have different color or
reflectivity.

The fiber is maintained
in front of the LED and the other end is routed
to face the sensor. You must take care to avoid
any gap between the connector holding the fiber
and the sensor to prevent direct light bleeding
from LED to phototransistor. The fiber must be applied
on the LED for best light coupling.

The LED light is greatly attenuated
by the fiber (the red glow proves that!). If you
use the barrier in bright ambient light, you must
shield it properly!

In order to try this setup, I use
it to count LEGO soccer balls that are notoriously
hard to detect because of the black dots on white
background.

Here is the simple NXT-G ball
counting program. An automatic calibration is
done at program start, light must not be blocked
at that time.

With a slightly improved program,
you may detect back to back balls easily.

In the same discussion, Brian Davis
suggested the use of fiber optics on the phototransistor
to improve spatial resolution of the light sensor.
In order to test this concept, I built this contraption
with three light sensor and a LEGO lamp (turning
on sensor LED completely wash out the faint light
received through the fiber). Three fibers close
to each other should be able to detect black lines
on paper.

Unfortunately, I was not able to get it work
correctly. Sensitivity is very low and readings
are very easily perturbed by ambient light.