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.
- Photo Resistor
- Resistor (10k)
- 3 Jumper wires (yellow, red & black)
- USB cable (A to B)
- A typical photo resistor has 2 leads. Choose one lead to be positive and one lead to be negative. Place it on the breadboard.
- 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.
- 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.
- Place the other lead of the (10k) resistor a few rows up/down and wire (red) it to 5V on the Arduino.
- Place a (black) wire in the same row as the negative lead of the photo resistor and wire it to Ground on the Arduino.
- Connect the Arduino to your computer with the USB cable (A to B).
- 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.
int lightPin = 0;