Photoresistor tutorial.

Photoresistors are used to measure light, but they aren't terribly accurate. They vary from sample to sample, and are generally not characterized (tested for performance) by the manufacturers. The average photoresistor would not be used for determining the absolute amount of light hitting it, but for measuring relative amounts of light. For absolute light levels we would use a PIN diode. Armed with the knowledge that the resistance of the photoresistor decreases with increasing light, we can build a device that controls a process based on the brightness of the environment.

A photoresistor is not a resistor

A resistor doesn't change its value with light, but a photoresistor does. That is because it is not made of resistive material, but semiconductor material, a little like transistors. Most semiconductors are light sensitive, so they are wrapped in light-proof packages, with the exception of photodiodes, phototransistors, and photoresistors, which of course need to be exposed to light to function.

The circuit consists of a photoresistor, a sense resistor, and the Arduino Uno. The voltage across the sense resistor increases as the light increases. This is because the photoresitor's resistance decreases, allowing more current to flow through the sense resistor. The voltage is measured by the Arduino to determine the amount of light hitting the photoresistor. We are going to make an LED glow dimmer when it gets dark by using the photoresistor to sense the light.

For the sensor part, we hook the photoresistor and the sense resistor in series, then hook the open end of the sense resistor to ground and the open end of the photoresistor to +5V. The center point is the where the Arduino will measure the voltage. Connect that point to the A0 pin.

For the process to control, we hook the cathode of the LED to ground, the anode to a 1kΩ resistor, and the other end of the resistor to pin 9 on the Arduino.

On the Breadboard

Here is a picture of my breadboard with the circuit built. It requires a 80kΩ to 120kΩ resistor for the sense resistor, a photoresistor, an LED and a 1kΩ current limiting resistor. The following sketch will send the ADC value to the serial monitor, and then divide it by four to send to the PWM analog output pin. It divides by four because the ADC's 10-bit range is four times larger than the 8-bit range of the PWM timer.

void setup() {

void loop() {
  int value;

  // Read the 10-bit value from the ADC
  value = analogRead(A0);

  // Output an 8-bit value to the PWM.
  analogWrite(9, value / 4);

Different Photoresistors

Photoresistors are specified by their dark resistance and their resistance at some specific light level. The particular photoresistor used in this tutorial is 1MΩ dark and 10kΩ under bright room light. You can use any photoresistor that has a dark resistance greater than 100kΩ for this circuit. If your photoresistor has less dark resistance, you will need to choose a lower value for the sense resistor. Make it about 1/10 of the dark resistance of the photoresistor.

Arduino Board Logo


Arduino-Board is the go-to source for information on many available Arduino and Arduino-like boards, tutorials and projects.

Help and Support


Stay updated

Sign up if you would like to receive our once monthly newsletter.