Reading A Photo Resistor using ADC


Results 1 to 10 of 10

Threaded View

  1. #7
    Join Date
    Apr 2006
    Posts
    92


    Did you find this post helpful? Yes | No

    Default

    Hi,

    I do this all the time. I have found that using adcin is best. Use the adc pins of your pic like the PIC 18F452.

    TRISA = %11111111 'Set PORTA to all input
    ADCON1 = %10000010 'Set PORTA analog and right justify result

    adcin 1, photoVar 'read analog input of the photocell wired as a voltage divider input on pin 3 of Pic 18F452: result is stored in variable "photoVar"

    use the result stored in the variable "photoVar" to do something

    From what I understand, from the literature, adcin is a much better choice if your PIC has built-in analog to digital conversion such as the RA pins of Pic 18F452

    This is how you would wire your photocell:
    Scroll down the page and see the photocell, which is wired as a voltage divider.
    http://www.phidgetsusa.com/tutorials...ue_sensors.asp

    Oh, I also just wanted to say that using a solar cell would be cool but solar cells are more costly than photocells. If you wanted to store energy I would say use a solar cell, but from what I understand about your application a photocell, which costs maybe $1.00 at the most would be very effective.

    The Hot wire to +5
    the green to the pic pin
    the black to ground

    I make MIDI controllers that use a photocell to detect changes in light and dark, and in response produce MIDI notes. MIDI notes (messages) need to be very fast, the photocell and ADCIN are very fast. It's all you need for your application.

    If you need help let me know.
    Last edited by TonyA; - 24th January 2007 at 23:38.

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 : 0

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