Reading analog sensors without an ADC

Wiring is simple using the Adafruit Pi Cobbler. Connect the blue right rail to ground and the red left rail to +3.3 V. Then connect one side of the photocell to 3.3 V and the other side to Pi GPIO #18 (you can use any pin but the example code is for #18). Then connect a 1uF capacitor from #18 to ground. Make sure the negative side of the capacitor (marked with a minus (-) down the side if its electrolytic) goes to ground. The capacitor just needs to be rated for +5 V or greater, its really unlikely you’ll find a 1uF that has less than 16 V rating.

photocell

Now on your Pi, make sure you’ve installed RPi.GPIO.