Difference between revisions of "Ambient light color sensing"
Line 18: | Line 18: | ||
== Circuit == |
== Circuit == |
||
[[Image: |
[[Image:Photo_circuit.jpg]] |
||
== Code == |
== Code == |
Revision as of 09:18, 5 February 2008
Original Assignment
The goal of this project is to build a sensor that can detect the color of light produced by an LCD projector (such as the one in the lab). The sensor will consist of three tightly bundled phototransistors (e.g., the OP506B from digikey), each with its own color filter (see, for example, this description of color filters). Three analog inputs will read the sensed values and the program will print the RGB (or similar) values to an LCD screen (see, e.g., C_Example:_Serial_LCD or C_Example:_Parallel_Interfacing_with_LCDs). The demonstration will show these values changing as you move from one part of the projected image (a simple test pattern consisting of single-color blocks) to another.
Overview
A phototransistor will alter its emitter current according to the amount of light shone upon its base input. Thus, the current will be at its maximum when the transistor receives the most light, and at a minimum when it receives no light. To translate this current into a voltage measureable by the PIC, the voltage can be probed across a resistor placed in series following the emitter portion of the phototransistor. This means that maximum voltage (at maximum light exposure) should be approximately equal to the input voltage at the collector, minus the voltage drop across the transistor, and the minimum voltage should be approximately zero.
To split the source light into separate colors, color filters must be used to block out other wavelengths of light. A red color filter will only allow red light to pass through (650 nm), a cyan filter will only allow cyan light to pass through, and a green filter will only allow green light to pass through (510 nm). These three filters will split light into Red-Green-Blue (RGB) components, a common quantification of the visible spectrum in PCs. Note that phototransistors may be sensitive to differing wavelenghs of light, usually visible light or IR phototransistors- make sure you choose the correct one for your purposes.
Once you have three different phototransistor voltages that are dependent on 3 RGB values, each one can be connected to the PIC via an analog input. While the voltage read may be between 0 and 5, it can be adjusted linearly to a scale from 0 to 255, the range for an RGB value. Each transistor will have a value from 0 to 255, which can then be reconstructed back into a single color on the computer, or can be printed out to an LCD screen.
Phototransitors can be purchased through digikey. Color filters may be ordered here.