ZachLabs Arduino

Lab 4: Photoresistors

A photoresistor, or photocell, is a resistor that changes resistance based on light. As more light shines on a photoresistor its resistance decreases. The photoresistor in your kit has a resistance of around 100 kΩ in the dark and 1 kΩ in the light. By combining it with another resistor you can create a light sensor, which you will do in this lab.

Example Program

Assemble the following circuit and upload the program to your Arduino:

Make sure that you use a 10 kΩ resistor as indicated, not a 330 Ω resistor like in previous labs.

void setup()
    pinMode(A0, INPUT);

void loop()

If you open the serial monitor in the Arduino IDE you should see a stream of numbers being printed to it, with values between 0 and 1023 that change as you cover and uncover the photoresistor and change the amount of light shining on it.

Learn More


Create a circuit that detects when someone puts their hand in front of the photoresistor and blinks a pattern (of your choosing) on an LED, sort of like a hands-free paper towel dispenser. You will need to experimentally “calibrate” your photoresistor and determine the threshold at which it should turn on. Printing the values returned by analogRead() to the serial monitor like in the example above is an easy way to do this.