Flip LDR and R1???
Flip LDR and R1???
Dave
Always wear safety glasses while programming.
Hi mackrackit, I tried that, but the motor stays on in light or dark.
Someone told me that in that case, I need to increase the Ohms of R1. (R1 is currently 10k Ohm, 1/2 watt.)
I'm not too proud to say that I know NOTHING about what we are talking about here. How do I figure out what R1 needs to be?
LSD and R1 are creating a voltage divider that will bias the transistor.
Think about the resistance of the LDR in light or dark , measure it.
Then use a voltage divider formula to figure what R1 should be to bias the transistor.
Probably the easy thing to do is make it adjustable. Replace R1 with a pot.
LDRs are all different under different lighting.
Dave
Always wear safety glasses while programming.
Is this a new post or revival of a very old one? Either way, this approach is not very good on many many levels. BrianT is dead-on.
Here are some questions to ask to start with:
No where is it mentioned how big this motor is. This will directly effect how big the transistor is. So there is the first question; how much current do you need and what is the in-rush current going to be? Ignore in-rush to your own peril (I've seen TO-3 cans vaporized). Once you answer this you can then decide whether an NPN will do it, or do you need something more like a Darlington device? You'll want to keep loses to a minimum and deal with the in-rush so at the very least we know we can use PWM. This can control in-rush as well as give speed-control (if you want).
LDR's are notoriously loose in their tolerance. Do you actually need an LDR or would a photo-diode be a better choice? In either case you have to consider hysteresis. If you do not then you can very easily get into a situation where the motor will stutter if a cloud or a person passes by. The simplest thing would a comparator (useful but) use an ADC and perform hysteresis in software. This is all going to be very low speed stuff so you have tons of time to measure the "photo-detector".
I see one of the 8 pin PIC's with pins left over to drive a led or two for whatever, measure battery voltage for an under-voltage lock-out, measure current, serial output...
Mike Tripoli
Look at the circuit I posted here
http://www.picbasic.co.uk/forum/show...4777#post84777
You can actually add this functionality to to a PIC timer (one that acts as a timer using timer0 and/or timer1) and does not use an RTC , your choice though).
By adding the timer to it you could do something like :
You could also go on to add things like a temperature controller and humidity sensor.Code:IF daylight AND time is daytime THEN motor_pin OFF
All of these combined could determine whether it is dark outside because of rain or a storm or a passing aeroplane or bird or insect on the sendor :-)
So our light sensor becomes quite a smart device.
Anyways , just a thought :-)
Kind regards
Dennis
Last edited by Dennis; - 28th February 2010 at 12:55.
Bookmarks