Sparkfun: Mini Photocell

From eLinux.org
Revision as of 20:30, 23 September 2012 by Popenhjc (talk | contribs) (Bone Usage)
Jump to: navigation, search


Overview

The: product. The datasheet.


Inputs and Outputs

As for inputs and outputs, the sensor is basically a resistor and thus should be read from the analog input pins. To work with the analog input, you must put 1k ohm resistor from analog ground to the analog input you choose then connect the sensor from the analog VDD to the analog input you choose. The input voltage can then be read by the processor to interpret the amount of light in the room.

Bone Usage

To interface this with the BeagleBone you just need to connect the photo-resistor from the analog VCC to an analog input and another resistor (I used 1.1kohms) from analog input to analog ground. From there you can read the voltage input and manipulate it using code however desired. In my case I basically took the number that the analog input gave me and manipulated it to work as the duty cycle for a pwm which dimmed the light if it was too bright and brightened the light if it was too dim. You can see this in the sample code provided.

Reading and Interpreting Analog Input Data

Sample C Code