Light sensors measure the amount of light impacting a photocell, which is basically a resistive sensor. The resistance of a photocell is
low when it is brightly illuminated, it is high when it is dark.

Light sensors can measure:
 Light intensity (how light/dark it is)
 Differential intensity(difference between photocells)
 Break-beam (change/drop in intensity)

Optical Sensors
Optical sensors consists of an emitter and a detector. Depending of the arrangement of emitter and detector relative to each other, we can get two types of sensors:
 Reflective sensors (the emitter and the detector are next to each other, separated by a barrier; objects are detected when the light is reflected off them and back into the detector)
 Break-beam sensors (the emitter and the detector face each other; objects are detected if they interrupt the beam of light between the emitter and the detector)

The emitter is usually made out of a light-emitting diode (an LED), and the detector is usually a photodiode/phototransistor in Reflective
optical sensors. A light bulb in combination with a photocell can make a break-beam sensor.

Light Reflective Sensors
Light reflectivity depends on the color (and other properties) of a surface. It may be harder (less reliable) to detect darker objects this way than lighter ones. In the case of object distance, lighter objects that are farther away will seem closer than darker objects that are not as far away.

What can be done with light reflectivity?
 object presence detection
 object distance detection
 surface feature detection (finding/following markers/tape)
 wall/boundary tracking
 rotational shaft encoding (using encoder wheels with ridges or black & white color)
 bar code decoding

Light Sensors Calibration
Source of noise in light sensors is ambient light. The best thing to do is subtract the ambient light level out of the sensor reading, in order to detect the actual change in the reflected light, not the ambient light. This done by taking two readings of the detector, one with the emitter on, and one with it off, and subtracting the two values from each other. The result is the ambient light level, which can then be subtracted from future readings. This process is called sensor calibration.

Beam-break Sensors
Any pair of compatible emitter-detector devices can be used to produce such a sensors, for example: an incandescent flashlight bulb and a photocell, red LEDs and visible-light-sensitive photo-transistors or  infra-red IR emitters and detectors

Infra Red Sensors
Infra red sensors are a type of light sensors, which function in the infra red part of the frequency spectrum. IR sensors are active sensors: they consist of an emitter and a receiver. IR sensors are used in the same ways that visible light sensors: as break-beams and as reflectance

IR is preferable to visible light in robotics applications because it suffers a bit less from ambient interference, because it can be easily
modulated, and simply because it is not visible.