Exit the Python Console by typing:
>>> exit()
Enter the following command to create a new files called light.py
nano light.py
import Adafruit_BBIO.ADC as ADC import time sensor_pin = 'P9_40' ADC.setup() print('Reading\t\tVolts') while True: reading = ADC.read(sensor_pin) volts = reading * 1.800 print('%f\t%f' % (reading, volts)) time.sleep(1)
To start the program, enter the command:
python light.py
Reading Volts 0.000556 0.001000 0.000000 0.000000 0.026111 0.047000 0.448889 0.808000 0.449444 0.809000 0.452222 0.814000 0.730000 1.314000 0.738889 1.330000 0.722778 1.301000 0.726111 1.307000 0.445556 0.802000 0.401667 0.723000 0.717778 1.292000
The readings taken are not in any useful units of light intensity. Photoresistors are not carefully calibrated sensors. If you wanted to make a light meter, with absolute measurement of light intensity in meaningful units, you would need to create a lookup table that related readings with readings taken from a properly calibrated light meter.