Before writing a Python program to measure and report the light level, we can try some experiments in the Python Console.

To launch the Python Console type:
# python
Python 2.7.3 (default, Apr  3 2013, 21:37:23) 
[GCC 4.7.3 20130205 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
First, we need to import the library, so enter the command:
>>> import Adafruit_BBIO.ADC as ADC
Now enter the command below into the Python Console to setup the ADC (Analog to Digital Convertor).
>>> ADC.setup()
You can now read the value at the analog input (between 0 and 1) using the command below. Try it a few times while moving your hand closer to and further away from the photoresistor. The readings should change in response to your hand movements. Cover the photoresistor completely and the reading should drop almost to 0.
Note: Using the up arrow will repeat the last line that you entered in the Python Console.

This guide was first published on Jul 01, 2013. It was last updated on Jul 01, 2013.

This page (The Python Console) was last updated on Jul 01, 2013.

Text editor powered by tinymce.