Datasheet

BONUS! Reading Photocells Without Analog Pins
Because photocells are basically resistors, its possible to use them even if you don't have any analog pins on your
microcontroller (or if say you want to connect more than you have analog input pins). The way we do this is by taking
advantage of a basic electronic property of resistors and capacitors. It turns out that if you take a capacitor that is
initially storing no voltage, and then connect it to power (like 5V) through a resistor, it will charge up to the power
voltage slowly. The bigger the resistor, the slower it is.
This capture from an oscilloscope shows whats happening on the digital pin (yellow). The blue line indicates when the
sketch starts counting and when the couting is complete, about 1.2ms later.
This is because the capacitor acts like a bucket and the resistor is like a thin pipe. To fill a bucket up with a very thin
pipe takes enough time that you can figure out how wide the pipe is by timing how long it takes to fill the bucket up
halfway.
© Adafruit Industries https://learn.adafruit.com/photocells Page 17 of 25