Reading A Photo Resistor using ADC


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    jessey's Avatar
    jessey Guest

    Default Reading A Photo Resistor using ADC

    Hello,

    I'm looking to write some code to detect a varying light level using a photo resistor. I've tried using the pot command but it doesn't seem to be suitable for my application. I would like to be able to detect dawn (sun just beginning to rise) and dusk. Using the pot command works somewhat but not with any kind of repeatable accuracy.

    I read in the archives about using the ADC to read a photo sensor but I'm not sure how to get started doing that. I won't have any problems to set up and get the ADC working but what I'm not sure about is how to wire the photo resistor to the adc input. Once I get the photo resistor wired properly and see what the photo resistor is inputting to the ADC then I shouldn't have any problems writing the code for that.

    Could anyone here suggest a wiring scheme and possible considerations for accomplishing this? Or another method that would be suitable.

    Thanks
    jessey

  2. #2
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    I used a LDR to detect when the main lights on my fish tank went out so it would turn on the night lights for a set period of time. This used a 12F675, and the LDR simply connected between a pin on the PIC and GND.

    As I was simply using it for "logic" (ie is it dark - yes / no) rather than actually measuring the level, the ADC function of the PIC was disabled.

    If its any help the project files can be downloaded from my website via the link in my signature

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    RCTIME works pretty well for something like this. Here's an example with
    simple schematics http://www.rentron.com/Micro-Bot/CDS_IR_Navigation.htm

    You could replace the 0.01uF caps with resistors forming a voltage divider
    with your CDS photocell then read the output with an A/D pin just as easily.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382


    Did you find this post helpful? Yes | No

    Default

    I have a related question. What if you wanted to sense the frequency that a light was turning on and off? (nothing more than 60hz)

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    You would want a sensor with a much faster response time than a CDS
    photocell. Check here http://www.taosinc.com/index.asp

    They have a lot of nifty optical gadgets.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  6. #6
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382


    Did you find this post helpful? Yes | No

    Default

    makezine.com had a post about using a solar cell. Do you think that might work?

    You can find the instructable here:
    http://www.instructables.com/id/E5KC...FO02Y?ALLSTEPS

Similar Threads

  1. Stable Adc Reading Routine
    By gebillpap in forum General
    Replies: 27
    Last Post: - 13th May 2015, 02:18
  2. Reading (ADC) negative current
    By sougata in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 21st November 2006, 17:38
  3. 12F675 ADC 'Issues'
    By harrisondp in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st March 2005, 01:55
  4. Problem reading multiple ADC ports
    By jswayze in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 4th November 2004, 16:46
  5. Reading multiple ADC channels FAST
    By lwindridge in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 21st April 2004, 22:37

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts