November 21, 2024, 08:43:26 PM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


Light Sensors for the Prop-2 (Sensing light levels)

Started by datbates, June 07, 2007, 11:01:15 AM

Previous topic - Next topic

datbates

I am doing a project which will required me to sense the amount of light shining on a light sensor and use the amount to control some servos position.  What should I use for the sensor?

JonnyMac

You can build a light sensor from simple components: a resistor, capacitor, and a CdS photocell.  Here's the schematic:



Be sure to use a good quality capacitor; low-quality (paper) caps are leaky and will give inconsistent results.  Here's what a subroutine to read the sensor might look like:

Get_Light_Level:
  HIGH Sensor
  PAUSE 1
  RCTIME Sensor, 1, lightLvl
  RETURN


Of course you have to define the "Sensor" pin and the "lightLvl" variable as a word.  Note, too, that the ULN2x03 will interfere with this circuit.  You could connect it to P15 and then replace the upper group ULN2803 with a ULN2003, or if you need to connect the circuit elsewhere you can simply remove (clip it) the ULN input pin that corresponds to the I/O you want to use.

Once you get everything working and know what you lower and upper limit values from the sensor are you can scale them to create a servo-compatible output pulse.
Jon McPhalen
EFX-TEK Hollywood Office