---
+ Post New Thread
Results 1 to 11 of 11
  1. #1
    Junior Member level 2
    Points: 478, Level: 4

    Join Date
    Sep 2010
    Posts
    20
    Helped
    0 / 0
    Points
    478
    Level
    4

    How do you connect LDR sensors with a PIC ??

    Hi

    How do you connect LDR sensors with a PIC ??

    Im writting a code to read from both LDRs and show the reading on LCD and I want to see if it's working
    but I dont know how to connect the LDRs with the PIC??

  2. #2
    Advanced Member level 3
    Points: 5,488, Level: 17
    Achievements:
    7 years registered

    Join Date
    Jun 2007
    Posts
    819
    Helped
    209 / 209
    Points
    5,488
    Level
    17

    Re: How do you connect LDR sensors with a PIC ??

    Connect the one terminal of the LDR to +5V then the other terminal to the Analog input of the PIC

    ---------- Post added at 13:46 ---------- Previous post was at 13:44 ----------

    drskippy.net/projects/ProgrammableLED.pdf



    •   Alt3rd October 2010, 14:46

      advertising

        
       

  3. #3
    Junior Member level 2
    Points: 478, Level: 4

    Join Date
    Sep 2010
    Posts
    20
    Helped
    0 / 0
    Points
    478
    Level
    4

    Re: How do you connect LDR sensors with a PIC ??

    I tried that it didn't work



  4. #4
    Advanced Member level 3
    Points: 5,488, Level: 17
    Achievements:
    7 years registered

    Join Date
    Jun 2007
    Posts
    819
    Helped
    209 / 209
    Points
    5,488
    Level
    17

    Re: How do you connect LDR sensors with a PIC ??

    Which didnt work? The LDR or the PIC? Can post your codes here?



    •   Alt3rd October 2010, 14:48

      advertising

        
       

  5. #5
    Junior Member level 2
    Points: 478, Level: 4

    Join Date
    Sep 2010
    Posts
    20
    Helped
    0 / 0
    Points
    478
    Level
    4

    Re: How do you connect LDR sensors with a PIC ??

    Iam using assembly program to sense the sun light using 2 LDR and compare them and rotate the motor to the sun direction
    Last edited by zeeba; 5th October 2010 at 07:28.



    •   Alt3rd October 2010, 15:00

      advertising

        
       

  6. #6
    Super Moderator
    Points: 39,918, Level: 48

    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    6,725
    Helped
    2079 / 2079
    Points
    39,918
    Level
    48

    Re: How do you connect LDR sensors with a PIC ??

    It will not work with just the LDR. You need to measure voltage at one of the ADC inputs. The voltage comes from a potential divider made from a fixed resistor and the LDR in series with the ADC connected to the center. If you omit the fixed resistor the LDR will pull the PIC input high, even under dark conditions and the ADC will always read maximum voltage.

    Note that there are two ways you can connect this:
    1. LDR goes to the supply, resistor goes to ground.
    2. Resistor goes to supply, LDR goes to ground.

    Option 1 will give an increasing voltage as it gets brighter but you have to carry the supply line wherever the LDR is mounted. If it shorts to anything you could damage the supply or the wiring.
    Option 2 will give a decreasing voltage as it gets lighter but this is easy to compensate in software. It has the advantage that the LDR is grounded at one end and the resistor limits the current, giving some degree of protection.

    The optimum resistor value will give best voltage swing between lightest and darkest conditions. Typically, choose a value equal to the mid way between LDR dark and LDR light resistances.

    Brian.


    1 members found this post helpful.

  7. #7
    Full Member level 6
    Points: 2,453, Level: 11

    Join Date
    Sep 2009
    Location
    Some where In INDIA
    Posts
    345
    Helped
    73 / 73
    Points
    2,453
    Level
    11

    Connecting 5-ldr to PIC

    Hi all,
    We are planning to develop a Walking stick for Blinds. And we are planning to use 5 LDRs
    in it to sense Vehicle lights from
    1) Left
    2)Front-Left
    3)Front
    4)Front-Right
    5)Right

    Above The LDRs we are planning to put some Red LEDs to knotify the vehicles that a Visually Impaired person is in front of him.
    We need help in hardware designing/schematic.
    If this post is considered bad then I will start a new thread :???:
    else I will continue here

    Thanks
    Bluhole



  8. #8
    Full Member level 2
    Points: 601, Level: 5

    Join Date
    May 2014
    Posts
    130
    Helped
    1 / 1
    Points
    601
    Level
    5

    Re: How do you connect LDR sensors with a PIC ??

    Quote Originally Posted by betwixt View Post
    It will not work with just the LDR. You need to measure voltage at one of the ADC inputs. The voltage comes from a potential divider made from a fixed resistor and the LDR in series with the ADC connected to the center. If you omit the fixed resistor the LDR will pull the PIC input high, even under dark conditions and the ADC will always read maximum voltage.

    Note that there are two ways you can connect this:
    1. LDR goes to the supply, resistor goes to ground.
    2. Resistor goes to supply, LDR goes to ground.

    Option 1 will give an increasing voltage as it gets brighter but you have to carry the supply line wherever the LDR is mounted. If it shorts to anything you could damage the supply or the wiring.
    Option 2 will give a decreasing voltage as it gets lighter but this is easy to compensate in software. It has the advantage that the LDR is grounded at one end and the resistor limits the current, giving some degree of protection.

    The optimum resistor value will give best voltage swing between lightest and darkest conditions. Typically, choose a value equal to the mid way between LDR dark and LDR light resistances.

    Brian.
    Hello,
    What do you mean by "You have to carry the supply line"??
    I`m using this configuration, where the resistor goes to ground. What risks are you talking about, can you be more clear please?



  9. #9
    Super Moderator
    Points: 39,918, Level: 48

    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    6,725
    Helped
    2079 / 2079
    Points
    39,918
    Level
    48

    Re: How do you connect LDR sensors with a PIC ??

    This is an old thread!

    What I meant was that if the walking stick is conductive and connected to battery negative, for example many are lightweight alloys, and by it's nature likely to bump into things, it wouldn't be a good idea to run wiring from the supply to the LDRs and LEDS from the battery where it could short out and be a danger. The LDR is part of a potential divider, the other part being a fixed resistance. You measure the light level by reading the voltage at the center of the divider. If the LDR is in the ground side (more light = lower resistance = lower voltage) the fixed resistor limits the current that can flow into the LDR wires if a short occurs. If the LDR is in the supply side (more light= lower resistance=higher voltage) one of the supply lines has to travel to the LDR without any limiting resistance. This could,in some circumstances short out the battery.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.


    1 members found this post helpful.

  10. #10
    Full Member level 2
    Points: 601, Level: 5

    Join Date
    May 2014
    Posts
    130
    Helped
    1 / 1
    Points
    601
    Level
    5

    Re: How do you connect LDR sensors with a PIC ??

    This is How I connect the LDR, to any microcontroller:



  11. #11
    Super Moderator
    Points: 39,918, Level: 48

    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    6,725
    Helped
    2079 / 2079
    Points
    39,918
    Level
    48

    Re: How do you connect LDR sensors with a PIC ??

    Warning: if the potentiometer is set to zero Ohms (short circuit) and a bright light shines on the LDR it could burn it out. Always add a fixed series resistance to limit the LDR current. The transistor is almost irrelevant in that circuit, the volage can be taken from across the LDR itself.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



+ Post New Thread
Please login