Color sensors: Detecting colors
With a color sensor for microcontrollers, you can determine colors relatively easily using the RGB color spectrum, emitting light via the white LEDs located on the board. In the center of the usually four LEDs is a photodiode. This filters the reflected light optically and divides it into red (R), yellow (G) and blue (B) light components and measures the intensity (i.e. the ratio) of the individual color components. By measuring the intensity of the color components, the color of the object is accurately determined.
Photoresistor: Determine brightness with an Arduino microcontroller
The function of photoresistors is very similar to that of color sensors. However, unlike color sensors, with photoresistors we measure the intensity of ambient light. It is not possible to determine the exact color.
Functionality of photoresistors
With increasing light irradiation, the resistance drops. This effect is also called photoelectric effect. When the conductivity of the resistor increases, the measured value at the analog input of the microcontroller increases. When the light intensity decreases, the measured value decreases again and the resistance increases.