Author Options:

Assistance in designing an automatic room light controller? Answered

I am trying to build an automatic room light controller that will turn on a lamp when a person enters a room and maintains it in the on state as long as the room is occupied. once the room is empty, the lamp will switch off. I intend to use a PIC for this project, together with an infrared emitting diode and phototransistor for detecting entry and exit. But my major problem is making the circuit direction sensitive. How can I differentiate between entry and exit? I would really appreciate any help I can get. Thanks


Two sensors next to each other, and track the order in which they are blocked and unblocked. It will still run into trouble occasionally as more than one person enters or exits together, or in a few other situations, but that's the simplest answer.

BTW, the advantage of this sort of count-in/count-out mechanism is that you don't need the periodic movement to wake up the PIR or sound sensor. I've tried lights on IR motion-detector, and if you're sitting still for a long time -- reading or working at a computer -- they'll turn off. Admittedly you can wave your arms around and get 'em to turn back on, but it's still inelegant and somewhat annoying.

The counter does have the drawback that occasionally it'll get confused and you'll have to wave your hand thru the doorway once or twice to count it back to where it's supposed to be. I think that's probably less annoying, though, since it doesn't demand your attention except when you're walking past it anyway, and it'll usually work.

I've thought about doing something like this, but since I'm already pretty well trained to use light switches... My real nuisance right now is that the kitchen light is only controllable from one entrance, not the other; so walking through is a problem; I'll eventually fix that by rewiring it as two-way.

As Steve said, a PIR detector (or more than one) will do it well.

If it's a large room with multiple light sources, you can increase your scope by adding multiple PIRs that have a narrower radius of capture to zone the room (for instance in a large basement or a loft (the warehouse kind, not an "apartment" in the UK)

I wish I had a half dozen...I'd use them in my Kitchen, lav, attic, cellar, and closets...

 What about sound?  Have the PIC listen with a microphone for footsteps or some noise, turn on the light, and initiate a fairly long delay--minutes, then have it listen again.  If no sound is detected, turn off the light.  A shouted "hey" would turn it on if the person is too quiet to keep it on.  Maybe the light could flicker before going off to warn the person of impending darkness.

The problem with this is if there is noise outside the room, it might trigger the light.  That isn't necessarily bad, though.  Think burglar.  Anyway, set up the microphone with a sensitivity control so you can adjust it to normal room entry noise.

Just use a PIR sensor - OK, so the people have to move around, but there is no possibility of the thing being confused about who is in or out. You don't need a microcontroller to do this !

You could rig it up to the door. Open/close trips on-off. Or exterior handle turns-on, interior handle turns off (with delay).