Arduino: using a photo-resistor

A photo-resistor changes its resistance depending on how much light is shining on it. So you can use it as a light sensor.

The photocells we have work best when used with a pull-down resistor (sort of like the pull-down resistor we used on the pushbutton).

[photocell wired to Arduino]

Here's a diagram of how to connect it. It's probably best to use a 1kΩ resistor for indoors; if you'll be using it in bright light, use a bigger resistor, like 10kΩ.

The green wire is going to analog input pin 0 on the Arduino. The other two go to power and ground. Read analog pin 0 just like you did with the potentiometer.

Sample projects

An easy project to do with a photo-resistor is a light theremin -- an instrument that plays tones that vary with the light shining on it. Then you can play music by moving your hand up and down over it.

You could also use it, for instance, inside a dark cupboard or a box where you keep your private stuff, so it would sound an alarm when the door opens and lets the light in.

More complicated projects: you could put it on a car and make the car move when you shine a light on it, and stop when the light goes away (or vice versa). Or you could mount one pointing down on the front of a robot or car to make it follow a black line -- if it strays off the line, it'll see more light. (You might need to use two or even three photoresistors, so you can tell which way to go to get back to the line.)

Credits: This page uses a circuit image cribbed from LadyAda's detailed photocell tutorial.