Continue to Site

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.

  • 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.

LDR circuit

Status
Not open for further replies.

bananasiong

New Member
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.
 
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.
 
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.
 

Attachments

  • thermostat.GIF
    thermostat.GIF
    3.7 KB · Views: 1,752
Hero999 said:
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.
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?
 
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.
 
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.
 
oh, for this function, i don't reserve any pin from microcontroller for it, i simply need it to on when it is dark.
 
philba said:
I'm not sure how that circuit can be modified to meet the 3 level requirement.
What do you mean?

philba said:
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.
What are you talking about?

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

bananasiong said:
thanks, which npn and pnp should i use? can it be 2N3904 and BC327? how about the diode?
You don't need a diode for an LED basuce it isn't inductinve so there's no back EMF.

bananasiong said:
Is IN34 enough? Vcc to the 22K and GND to end of LDR right? I thought i need a VR to adjust the sensitivity?
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.

mramos1 said:
Does this help

**broken link removed**
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.

bananasiong said:
thanks for that!! can i just replace the relay with a LED or a bulb?
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.
 
Ldr Ckt

something simple like this do? :D
 

Attachments

  • LDR LED.jpg
    LDR LED.jpg
    38.4 KB · Views: 1,940
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?
 
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:
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:
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.
 
Hero999 said:
What do you mean?


What are you talking about?

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


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.

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

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!.
 
philba said:
as you can see, he wants 3 levels: full on, partial on, and off. I guess you didn't get that part.
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.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top