A few examples of devices that need light sensors to function properly:
Car headlights that automatically turn on when it’s dark
Streetlights that automatically turn on when it gets dark
Outdoor security lights that turn on when someone walks by (but only at night)
Laptop displays that get brighter in well lit areas and dimmer in poorly lit areas
Cameras with automatic exposure settings
The first three examples in the list are automatic lighting, and they depend on ambient light sensors to distinguish day from night. The electronics inside those devices only needs to know whether it’s light or dark, so they can treat their light sensors as binary outputs like pushbuttons. Laptop displays and camera auto exposures adjust to area lighting conditions by getting information from their light sensors about how bright or dark it is. They have to treat their light sensors as analog outputs that supply a number that indicates how bright or dark it is, much like previous potentiometer examples where numbers indicated the knob’s position.
INTRODUCING THE PHOTORESISTOR
Light sensors have many different functions, and they come in different shapes, sizes, and with different price tags. Some sensors are designed to sense a particular color of light, such as blue, green, red, or infrared. Some sensors don’t care what color the light is because they react to how bright the light is. Other sensors look for only special kinds of light given off by certain chemical reactions. Light sensors also have a variety of ways to tell a microcontroller what they see. Some sensors send a voltage, some send a sequence of binary values, and others react to different kinds of light or light levels by changing resistance.
Of the light sensors that react to light by changing their resistance, the photoresistor is probably the most common, least expensive and easiest to use. Its active ingredient is a chemical compound called cadmium sulfide (CdS). This compound changes resistance depending on how bright the light is that shines on its collecting surface. Bright light causes low resistance values between the