Photocells act as light sensors. Inlike infrared sensors that are good for line followers or detecting the presense of an object, photocells are good when you just want to detect light. For example, you might want a sensor that detects when a flashlight is on, or when the sun is out. Photocells are used in automatic night lights and in street lamps that turn themselves on at night. Sometimes known as photoresistors, photocells are available from a number of sources. They look like a small (0.5 to 2 inch) disk with two leads out the back. Radio Shack sells a multi-pak of cells for about $2.50 under part number 276-1657. A picture of one of the cells in this pack is shown below.

In operation, a photocell acts like a light sensitive resistor with a high resistance when dark and a low resistance when in the light. Photocell properties vary widely from model to model so you may have to do a lot of experimenting. You can test sensitivity to light by measuring the photocell resistance as you subject it to light and dark.

When using with a Arduino, the photocell is wired up in series with a fixed resistor so that the Arduino can read its output as a voltage. The schematic below shows the basic photocell circuit, except rather than digital I/O pin 1, connect to one of the analog input pins, for example analog pin 1 as shown, on the Arduino. The analog input pins are located on the other side of the board from the digital I/O pins.

Use this program to test the function of the photoresistor, examining its output while covering and uncovering the surface of the photocell to see what happens.

int val;
void setup() {
  Serial.begin(9600);     //  setup serial
void loop() {
  val = analogRead(1);    // read the analog input pin
  Serial.println(val);    // print to screen

In your application program, you can use the photocell as an intensity monitor by doing something with the value of the sensor. For example, you can look for a maximum as you rotate the sensor to determine when it is aimed at a light source. For this, enclose the sensor in an aiming tube to minimize any effect from side lighting. Or, you can use the photoresistor as a light switch by placing the analogRead() statement in an if() statement, for example

  if (analogRead(1) > 500) {
     ...insert commands here