Electronic – Fade in fade out proximity lighting

proximity-sensor

I want to light a miniature house …not “doll house” that can be played with , but the models like the period miniatures found in museums.

The lights in all rooms should come on simultaneously but slowly, over a period of say, 2-5 seconds when a viewer comes within 12-15 inches of the model.
I don’t want the lights going on simply when someone walks past the model at 3 feet away.

Lights should stay on as long as the person is within that 12-15” distance, then fade out slowly, again, over about 2- 5 seconds as they move away.
If another viewer comes up while the first moves away, and the lights dim a bit before lighting up again, or stay on, either way is OK.

Now for some background. I don’t know much about circuits. My dad (deceased) was a EE and I sometimes watched him tinker with stuff and asked questions. Then I took a basic Electronic course in junior college, but that was many moons ago. I do remember some principles and terminology.

I came across a design called a “Fade-in, fade out “ ckt for LEDS.
( Link attached)
http://www.pcbheaven.com/circuitpages/LED_Fade_In_Fade_Out_Dimmer/

It’s the first ckt shown, with the “slight flaw”

I bought some breadboard stuff and the parts on the parts list and used a 12v charger to power it. But I used a 2N2222 because my dad had a lot of those around.

The fade out works better, but the “fade in” is a little fast, but at least not like the typical LED sudden turn on (and off) .

Then I googled a lot on sensors and came across this Sharp sensor GP2Y0A02YK which seemed what I wanted. It’s weak at 3ft but seems to put out enough voltage at about 12-15 inches.

What I don’t know (and finally have come to my problem) is how to make this turn on and off the fader ckt.

I decided to try this: make the Sensor output turn on a second transistor (also NPN 2N2222– which I will call NPN-2 ) and put the entire fader ckt as the load in the NPN-2 collector . I really had/ have no idea if this is correct, but I figured a load is a load if there is enough current to make it work.

The 12 v charger is the Vcc ( I took the push button switch out of the Fader ckt and just made the 12v go straight to the resistor R1) , and made all the common points of the fader ckt go to the NPN-2 collector.

The NPN-2 emitter goes to 12v charger low side
The Sensor module itself is powered by 4 AA’s and its output goes to the NPN-2 base to turn it on (or not).
And surprise of surprises, the whole thing actually works! Well, not great, but pretty well.
So my questions are these.

1) Do I need resistor(s) in the base of NPN-2? It seems to work with one and without one. If I should have one/some there, what do I need?

2) How do I power the sensor module off the charger since it only needs 6v and not 12v?

3) How can I slow down the fade-in a little more ?

4) ) Is there a better way to do this? I.e. a better design, better sensor, just scrap the whole thing and start over?.

And finally 5) You all can stop rolling your eyes now.

Thank you

Marie

Best Answer

1) Your approach of switching the whole circuit is a bit strange, though it works in this case.

The base resistor should be small enough that the transistor switches on, but ensure that the transistor base isn't destroyed by excessive current.

(In other words, you are lucky that the output of the sensor is too weak to destroy the transistor.)

2) The sensor wants 5V for its power supply (see "Recommended operating conditions" in the data sheet). The easiest way to get that from 12V is with a 7805 voltage regulator. See the data sheet for suitable input and output capacitors.

3) You can increase the value of R1, but only so much that it still can switch the transistor on. Or you can increase C1, but then the fade out will also get longer. You can counter that by decreasing R2.

4) It would be better use an Arduino with PWM to dim the lights, then it would be easier get exact control of the timing. The sensor is a good choice for this application, you could hook it to an analog input and program the threshold.