How it works
A photoresistor (also known as a Light Dependent Resistor or LDR) is a passive component whose electrical resistance changes based on the amount of light striking its surface. In complete darkness, its resistance is extremely high (often several megaohms). When exposed to bright light, its resistance drops dramatically (often to a few hundred ohms).
Photoresistors are commonly used in voltage divider circuits to create a light-sensing voltage signal. This allows microcontrollers to detect day/night cycles, measure ambient light levels for automatic screen brightness, or trigger security alarms when a laser beam is broken.