Datasheet
CircuitPython
It's easy to read how much light a photocell sees with CircuitPython and its built-in analog input
support (https://adafru.it/CbI). By wiring the photocell to an analog input of your board you can read the voltage from it
and see how it changes as the amount of light hitting the sensor changes too.
First wire up a photocell to your board as shown on the previous page for Arduino. You'll want to setup the same
voltage divider with a 10 kilo-ohm resistor circuit and feed the output into any analog input on your board (note the
special method of reading photocells without an analog input is not currently supported by CircuitPython).
Here's an example of wiring a photocell to a Feather M0:
Board 3.3V to one leg of the photocell (doesn't matter which leg). Note you want to use the voltage from your
board that corresponds to the maximum analog input voltage. For Feather boards this is 3.3V, but for other
boards it might be higher or lower--consult your board documentation to be sure.
10 kilo-ohm resistor to the other leg of the photocell.
Board GND to the other leg of the 10 kilo-ohm resistor.
Board A1 (or any other analog input) to the junction of the photocell & 10 kilo-ohm resistor.
Next connect to the board's serial REPL (https://adafru.it/pMf)so you are at the CircuitPython >>> prompt.
Now import the board and analogio modules that allow you to read an analog input. Be sure you've read
the CircuitPython analog I/O guide (https://adafru.it/CbJ) for more background on using analog inputs too!
Create an analog input for the A1 pin connected to the photocell & resistor junction:
import board
import analogio
© Adafruit Industries https://learn.adafruit.com/photocells Page 21 of 25










