Posts about... All (17) Android (2) Hooking Up Parts (10) Game Controllers (3) Robots (2)

How to Hook Up > Photo Resistors

Photo resistors measure light. The amount of light varies the resistance and determines a value between 0 and 1023. This post details how to hook one up to an Arduino.

Parts

Steps

  1. A typical photo resistor has 2 leads. Choose one lead to be positive and one lead to be negative. Place it on the breadboard.
  2. Place a (yellow) wire in the same row as the positive lead and wire it to an Analog pin (0) on the Arduino. Leave room for 1 lead of a resistor.
  3. Place a one lead of a (10k) resistor in between the (yellow) wire to the analog pin and the positive lead of the photo resistor.
  4. Place the other lead of the (10k) resistor a few rows up/down and wire (red) it to 5V on the Arduino.
  5. Place a (black) wire in the same row as the negative lead of the photo resistor and wire it to Ground on the Arduino.
  6. photo resistor

  7. Connect the Arduino to your computer with the USB cable (A to B).
  8. The code below simply reads in the value of the photo resistor and outputs that value to the Serial Monitor within the Arduino software. Note: With the lights on, mine reads a value around 250. With the lights off, mine reads a value around 900.

Code

int lightPin = 0;

void setup()
{
Serial.begin(9600);
}

void loop()
{
Serial.println(analogRead(lightPin));
delay(100);
}