1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

LDR circuit

Discussion in 'Electronic Projects Design/Ideas/Reviews' started by bananasiong, May 11, 2006.

  1. bananasiong

    bananasiong New Member

    Joined:
    Mar 7, 2006
    Messages:
    1,893
    Likes:
    7
    Location:
    Malaysia
    hi all,
    i'm doing my final project, a robot mower. I want to include this feature:
    when the place is very bright, the LED is off.
    when it is not very bright, the LED on with low light.
    when it is dark, the LED is on with high.
     
  2. Dr.EM

    Dr.EM New Member

    Joined:
    Oct 27, 2004
    Messages:
    1,009
    Likes:
    1
    Location:
    UK
    I don't know how much current your LED needs, presumably its quite bright? The simple way would be to form a potential divider with the LDR and a resistor so that there is a point with a rising voltage in bright light. Then buffer/amplify this with a non-inverting op-amp configuration and use an emitter follower to power the LED and its series resistor from its output. If the LED needs a lot of current, a PWM system would be more suitable as to not waste battery power.
     
  3. bananasiong

    bananasiong New Member

    Joined:
    Mar 7, 2006
    Messages:
    1,893
    Likes:
    7
    Location:
    Malaysia
    i thought it can be done with transistor?
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Hero999

    Hero999 Banned

    Joined:
    Apr 6, 2006
    Messages:
    14,902
    Likes:
    79
    Location:
    England

    You could try this thermostat circuit I designed awhile ago, but replace the thermister with an LDR and the relay with an LED, the good thing is it has hysteresis to prevent oscillation.
     

    Attached Files:

  6. bananasiong

    bananasiong New Member

    Joined:
    Mar 7, 2006
    Messages:
    1,893
    Likes:
    7
    Location:
    Malaysia
    thanks, which npn and pnp should i use? can it be 2N3904 and BC327? how about the diode? Is IN34 enough? Vcc to the 22K and GND to end of LDR right? I thought i need a VR to adjust the sensitivity?
     
  7. philba

    philba New Member

    Joined:
    Mar 12, 2006
    Messages:
    1,886
    Likes:
    8
    Location:
    Seattle
    I'm not sure how that circuit can be modified to meet the 3 level requirement.

    I see several approaches that would work;
    - uC based. LDR+Resistor forms a divider that varies the voltage with the ambient illumination. divider output into the ADC. voltage value read is used to decide on one of 3 PWM duty cycles (100%, 50%, 0)
    - PWM circuit. sawtooth generator into one input of a comparator. LDR divider into the other comparator input. value of LDR divider will vary the PWM duty cycle. may need a driver transistor if comparator doesn't have the drive current. This varies the LED output continuously so it techniccally doesn't meet the requirements.
    - dual comparator. one comparator for each of the two transition voltages (ie light levels). each comparator contributes 1/2 the current for the LED. the comparator outputs are fed through current limiting resistors and connected to the cathode of an LED, anode is tied to +5V.

    schmitt triggers could be added but I kind of think a little flickering would be ok.
     
  8. mramos1

    mramos1 Active Member

    Joined:
    Sep 15, 2005
    Messages:
    2,403
    Likes:
    9
    Location:
    Boynton Beach, Florida USA
    You can take the LDR to VCC, a .2uF cap to ground, and tie the other two ends of them to a pin on the microcontroller, then write 0 to it for .250 secs, then read that pin (say 255 times) and count the number is HIGHs you have. See Nigel's joystick projects.

    I just did a project like yours, but rather an LED, I fired a buzzer, to let someone know the light was on. Works great other than battery life. Working on a fix for that now.

    There is a thread I think in the microcontroller forum only a couple days old.
     
  9. bananasiong

    bananasiong New Member

    Joined:
    Mar 7, 2006
    Messages:
    1,893
    Likes:
    7
    Location:
    Malaysia
    oh, for this function, i don't reserve any pin from microcontroller for it, i simply need it to on when it is dark.
     
  10. mramos1

    mramos1 Active Member

    Joined:
    Sep 15, 2005
    Messages:
    2,403
    Likes:
    9
    Location:
    Boynton Beach, Florida USA
  11. bananasiong

    bananasiong New Member

    Joined:
    Mar 7, 2006
    Messages:
    1,893
    Likes:
    7
    Location:
    Malaysia
    thanks for that!! can i just replace the relay with a LED or a bulb?
     
  12. Hero999

    Hero999 Banned

    Joined:
    Apr 6, 2006
    Messages:
    14,902
    Likes:
    79
    Location:
    England
    What do you mean?

    What are you talking about?

    That seems abig complex just for turning an LED on and off.

    You don't need a diode for an LED basuce it isn't inductinve so there's no back EMF.

    Yes you doo need a variable resistor, I was making you think, I did say it needs some modifications for it to work as you expect.

    There's nothing worng with that circuit but it depends on what you want to do, it's fine for switching low power loads with a relay but I wouldn't use it at high powers as the relay isn't snapped on and off, the current throught the coil changes slowly thus softening the switching action which can cause arcing at the contacts at high currents - not important for this application I'm just explaining things.

    Yes you can, (as I said before) this circuit is fine but you'll notice that the LED or bulb won't turn on or suddenly but will slowly get brighter or dimmer and it might vary with the temperature, is this behaviour acceptable?

    Also it isn't suitable for large light bulbs or high powered LEDs since the transistor will be getting quite warm when it isn't fully saturated.

    My circuit solves these problems (although it uses more parts) the LED/bulb will suddenly turn on or off, and it includes some hysteresis to help prevent oscillation.
     
  13. docel

    docel Banned

    Joined:
    Apr 9, 2006
    Messages:
    105
    Likes:
    0
    Location:
    Bangalore, S. INDIA.
    Ldr Ckt

    something simple like this do? :D
     

    Attached Files:

  14. dknguyen

    dknguyen Well-Known Member

    Joined:
    May 6, 2006
    Messages:
    6,668
    Likes:
    64
    Wow that so simple it blows my mind...does it work? Im not sure what LDR stands for, but I assume it outputs a voltage depending on brightness?
     
  15. docel

    docel Banned

    Joined:
    Apr 9, 2006
    Messages:
    105
    Likes:
    0
    Location:
    Bangalore, S. INDIA.
    It sure does! Light Dependent Resistor
    In bright light, LDR is low resistance and shorts out the LED.
    In Darkness, LDR is Hi resistance (>2Mohms) and led lights.
    In between the led dims proportionally, in an analog fashion.
     
    Last edited: May 13, 2006
  16. dknguyen

    dknguyen Well-Known Member

    Joined:
    May 6, 2006
    Messages:
    6,668
    Likes:
    64
    Ldr

    I think you can replace the LDR with a photo-transistor in Docel's circuit if you want on/off operation instead of dimming control...or it might end up doing the same thing if the switching thresholds of the transistor isn't narrow enough and the transistor's analog behaviour starts kicking in.
     
    Last edited: May 13, 2006
  17. Hero999

    Hero999 Banned

    Joined:
    Apr 6, 2006
    Messages:
    14,902
    Likes:
    79
    Location:
    England
    The LED won't be very bright with that circuit, the current will only be about 1.5mA in absolute darkness so you really want to be using one of those ultra bright ultra low current LEDs.
     
  18. philba

    philba New Member

    Joined:
    Mar 12, 2006
    Messages:
    1,886
    Likes:
    8
    Location:
    Seattle

    as you can see, he wants 3 levels: full on, partial on, and off. I guess you didn't get that part.
     
  19. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,203
    Likes:
    640
    Location:
    Derbyshire, UK
    Is it just me?, or does this seem a really silly thing to want to do? - a visual indication of how dark it is! - if you're looking at the LED to see how dark it is, why not just look how dark it is anyway?.

    I could understand an audible indication, but a visual one just sounds silly!.
     
  20. docel

    docel Banned

    Joined:
    Apr 9, 2006
    Messages:
    105
    Likes:
    0
    Location:
    Bangalore, S. INDIA.
    ;) ..and hence my silly circuit!!
     
  21. Hero999

    Hero999 Banned

    Joined:
    Apr 6, 2006
    Messages:
    14,902
    Likes:
    79
    Location:
    England
    Yes, I missed that part, but it was still a bit over complicated.

    I would use two comparators with open collector outputs, each would have different reference voltages and some hysteresis. The LED would have three series resistors at its ground connection, I would use the comparator outputs to short the appropriate resistor when it gets too dark, I canl draw to a diagram if you don't get me.
     

Share This Page