Connect with us

Motion sensor lighting with a difference

Discussion in 'Sensors and Actuators' started by themalloy, May 1, 2014.

Scroll to continue with content
  1. themalloy


    May 1, 2014
    Hi everyone, I am woking on a cusotm lighting solution to be fitted witin a lamp shade.

    I have hooked up a very modest setup using a power supply, PIR sensor and some LED strip lighting.

    It works however I need assistance now with the following requirements.
    1) Ability to turn on AND off LED’s by motion not just ability to turn on and have the LED’s turn off after a period of time.
    I have read that this is possible with a 'flipflop'. For example: wave over sensor to turn on and then be able to wave again to turn it off.
    If required it would be fine if I had to wait a few seconds before the second wave triggered the light turning off.
    (I have read that I could use an 'IR sensor switch' instead of a PIR sensor - this one is quite expensive but hoping there are others out there, alos this one appears to turn off if the hand pauses in front it will twinkle and turn off. I would ideally like the light to stay on the first time have a delay of a few seconds and then the next motion it detects turns it off)

    2) Adjust sensitivity of the PIR sensor.
    For example: I think most sensitivity ranges are from 5m - 10m. It would be best if we could decrease this to about 10cm
    The 'IR sensor switch' mentioed above can handle this but open to suggestions.

    3) Pulse effect when turning LED’s on and off. I dont just want the LED's to turn straighton and off.
    For example it would be nice if the light turned on subtly over a second and faded out over a second rather than turning straight on and off)

    It may require a brand new solution or add ons to the existing setup.

    Any help would be most appreciative.

    Kind regards,
  2. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    Nov 28, 2011
    Hi David and welcome to Electronics Point :)

    Thanks for the nice clear explanation.

    So you have a PIR sensor that you want to be able to use to control some LED strip lighting. You want to be able to wave near the PIR sensor to turn the LEDs ON, and wave again to turn them OFF, and you want them to fade ON and OFF over a period of about a second.

    It's certainly possible to make a circuit to do this. A flip-flop can be used to handle the ON/OFF toggle, and a technique called PWM (pulse width modulation) can be used to control the brightness of the LEDs. You would need to make up a small circuit board with a number of ICs (silicon chips) on it, as well as some small components.

    I guess the PIR sensor has an output that currently goes active when movement is detected, and stays active for a period of time, then times out and turns OFF until movement is detected again, right? With that circuit, you will need the PIR sensor to produce a signal each time movement is detected, with no hold-on period. Can the PIR sensor be configured to do that? Also, as you say, you will need to reduce its detection range, otherwise it will respond to movement in the room generally, instead of just movement near the lamp.

    To start with, can you answer some questions:

    What supply voltage are you using for the LED strip lighting?

    Do you have a manufacturer and model number for the LED strip lighting?

    Do you have a manufacturer and model number for the PIR sensor?

    Do you have any experience building electronic circuits? Do you have a multimeter?
  3. themalloy


    May 1, 2014
    Hi Kris,

    Thank you very much for the welcome and your detailed response.
    You have summed up my requirements perfectly :)

    I am happy to go with new parts that you suggest to make this circuit.
    Especially as this PIR sensitivity only reduces to a couple of meters whereas I would like it to work at about 10cm. An IR Sensor looks like a good option like this one (It would be good to have it in a smaller size as the space I want to position it is not that large)

    To answer your questions:
    Power supply: 12VDC 5.0A
    The strip lighting doesn't have a model number but it is 12V
    The PIR sensor does not have a model number either.
    I have a multimeter and and able to build basic circuits.

    Thanks again for your help.
  4. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    Nov 28, 2011
    OK. Do you know the current draw, or the rated power, of the strip light?

    Re the proximity sensor, it would be helpful if you could choose one and make sure it does what you want. Infra-red or ultrasonic would be suitable I think. It needs to run from 12V or some lower voltage. I'm going to assume that the sensor provides either a switched voltage output, or a contact that closes to complete a circuit. It needs to produce an active output when (while) proximity is detected.

    Thanks for the link to that YouTube video. That sensor would be suitable, in the second mode. In that mode, it actually turns its output OFF when proximity is detected, instead of ON, but it doesn't matter. What matters is that the output is in one state while proximity is detected, and in the other state when no proximity is detected. That detector also has a range of only 1~2 inches which isn't enough for you, but in other respects it is suitable.

    Here are some places to start looking:

    I will have a think about driving circuitry and I should have a suggested diagram up within a week or so. I hope that's OK.
  5. themalloy


    May 1, 2014
    Hi Kris,

    Thank you very much for all of your replies to date they have been most helpful.

    I am getting there with this project an learning lots of new things I think I have a good idea of how to achieve what i am trying to achieve now.

    I have attached some images for you of the light enclosure I am designing which will hep this discussion. 1.jpg 2.jpg

    The LED’s will fit inside the rear of the light, I need the sensor to fit in there swell as some sort of device to control the LEDS so they switch on and off gradually over the course of a second or so for good effect. You mentioned PWM which looks ideal.

    The point which I probably didn’t mention accurately enough earlier is the light once initiated needs to stay on until someone turns it of via the sensor.

    The idea behind the light is that someone can place an object inside the light shelf and this will trigger there light to fade ON. The light should then remain until someone takes the object out which intern triggers the sensor to turn the light OFF again. The light should not turn OFF automatically after a period of time.

    The strip lighting will be this:

    2) PWM controller
    This looks ideal:

    3) Sensor
    This is what I need help with.
    PIR sensors are not a good option as the ranges are too sensitive.

    I like these but not sure if they will work with the strip lighting and PWM module above and not sure if they will actually keep the light once activated

    Otherwise there off the shelf sensors like this (but i'd rather get the raw parts as they are more easily configurable - and cheaper)
    (not sure if this would work as if your hand pauses in front of it, the light will twinkle 3 times and turned off automatically)

    (the ranges are probably ton small)

    My only worry is that the sensor will need to be placed behind a wall of either thin veneer wood or perspex. I need something that will still have the ~10cm range (adjustable if possible) even placed behind something like the veneer or perspex (or any other material that will hide it but still allow it to work)

    4) Power supply
    Lastly a power supply - this shouldn’t be too difficult. Although the smaller the better as it needs to fit in at the rear of the light.

    I appreciate any feedback you can provide.

    Have a great day.
  6. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    Nov 28, 2011

    Thanks for that. I think I get the idea.
    OK, that's different from how you explained it on the thread. The PWM fade-up/fade-down is pretty straightforward, although of course there are several options for how to do it. But I think we need to mainly focus on detecting the presence and absence of this "object" on the light shelf - I assume you mean the shelf that the light is sitting on?

    I guess you will have the light suspended somehow, pointing downwards, and the "object" will be placed below it, right? So there will always be something below the light; it's just the distance to it that is significant.

    At this point I think it would be helpful if you told me about the project instead of using vague words like "object". As long as that won't violate any non-disclosure agreements, international treaties, inter-governmental contracts, or pinky promises that you are bound to observe.

    We first need to decide on the proximity detection method. This depends on the characteristics of the "object" - shape, size (height range and "floor area"), colour, reflectiveness, etc. Ultrasonic detection can determine distance, which would be a big advantage, but a standard detector could have problems due to bursts of ultrasonic sound bouncing around inside the enclosure. Infra-red, to my knowledge, only shines a light and detects the brightness of the reflection; this would work if the "object" is reflective and has a flat top surface, and the shelf surface is matte black. Another option might be a tray suspended from the lamp, which is weighed down by the "object", or a stand for the "object" to sit on, that connects back to the lamp. You may be able to think of other options.

    OK, those look fine. They require 12V and draw 55 mA per segment. Each segment is 50 mm long and has three LEDs. How many segments are you intending to use?
    That won't give you a fade-out; it just does a fade-in. That's because it's controlled by the incoming power; when power is applied, it does the fade-up, and when power is removed, there's no power any more so the LEDs go out immediately. You need a PWM controller that is powered at all times, and has a control input to tell it when to turn ON and when to turn OFF. This function could be combined with the proximity detection, in a single microcontroller.
    Also, I believe PIR sensors respond to movement of heat; your "object" presumably will not be warmer than ambient, and once placed, it will not move around. Also, if the LEDs are many, and bright, this could cause heating in the object, which might perhaps cause a problem.
    (a) is an ultrasonic distance measuring module. It needs a regular trigger pulse, and it provides its output as a pulse whose width corresponds to the distance measured. It would need to be connected to a microcontroller; this microcontroller could also perform the PWM generation.
    (b) uses infra-red light to detect proximity. I have no experience with this kind of sensor; I don't know how it works - I assume it shines a light and measures the brightness of the reflection, but I may be wrong - and I don't know what kind of objects it can reliably detect and whether it would be affected by the reflection of the illumination LEDs from the object. I suggest you buy one and experiment with it.
    (c) uses infra-red light but I'm not sure how it works. It also seems a bit expensive. I suggest you buy one and play around with it.
    (d) seems to be close to what you want - it has a fairly small range, at least - but it says it may not work with "black, transparent or translucent" surfaces. Its output is the opposite of what you want - it turns OFF when proximity is detected, but that can be reversed in the PWM control circuit. Again, buy one and have a play.
    (e) is similar to (d) but it includes a second operating mode where the output toggles from OFF to ON or from ON to OFF when proximity is detected. Again, buy and try if you want.
    I would say that would be a problem for any of these options.
    You want to be able to power the lamp directly from the AC mains? What about safety and fire risks? A type-approved wall wart would be simpler.

    The size of the power supply depends on how much power it needs to provide, which depends on the number of those LED strips you want to use. Each strip draws 55 mA at 12V which is about 0.7 watts. Control circuitry's load will be less than that. Add them up and see what size power supply you will need.
  7. themalloy


    May 1, 2014
    Hi Kris,

    Thank you again for your prompt reply.

    1) LED Strips
    I am set on these LED strips:
    12v 55mA per segment. There will be 10 segments used.

    2) Sensor
    I have gone ahead and said I will use this IR sensor switch for the ON/OFF function of the light:
    It can be run off 12 volts too.

    Note: I will get the project running using this sensor to begin with and then I may change the sensor later as ideally I would like a bigger range and possibly a smaller size sensor. I am not convinced this is the best sensor but like I said I really need to get the project working first then can play around with different sensors.

    I am really open to any suggestions here.
    I have also brought the sensors listed in the thread above to play around with at a later stage.

    3) PWM Module
    I now need some assistance with a PWM module that can be connected to this setup to ensure the light turns ON and OFF with a fade effect. Ideally over the course of a second or two.

    As you say the PWM controller to be powered at all times. so it works both when turning ON and OFF.

    It would be ideal if I could purchase a plug and play type module as I am rather a novice. If need be though I will create the PWM from your suggestions.

    4) Power supply
    In regards to the Power supply.
    I’m open to suggestions. There will be 10 LED strip segments used.
    As this is a design project I am wanting the smallest and best looking power supply.
    As you say a wall wart seems to be ideal.

    5) Some more information on the project to assist:
    The lighting enclosure will be made of copper.
    This is a design project and I am assisting with the lighting portion. We are hoping to exhibit it at an upcoming show in June. So timing is of the essence :)

    The light enclosure will either sit on bedside table or be placed on some sort of tripod.

    When I said an item will be placed inside this is the novelty of the light. The whole idea is that a child may have a surprise for Mum or Dad, they could pop an object say for example a letter or note or small toy (anything of this nature), by them putting their hand inside the light it will trigger the sensor and turn on the light. When Mum or Dad comes home they can see that the light is on and knows there is something in there waiting for them. Could also be used to place mail in there.

    Of course I will need to get it tested by a third party to ensure if it safe and meet all the regulations.

    Kind regards,
    Last edited: May 10, 2014
  8. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    Nov 28, 2011
    OK, good.
    OK. I'm not sure how you intend to distinguish between an object under the lamp, and the surface of the shelf under the lamp. If you want to return to the original behaviour, when movement of the child's hand will trigger the light to turn ON, then movement later will trigger it to turn OFF, then I can see that could be workable. The control circuit should enforce a few seconds' delay from one detection (that starts the ramp-up) until another detection is accepted (to start the ramp-down), so the lamp won't ramp up and down while the child is positioning the object.
    Fair enough.
    Well, I've done a web search and I haven't been able to find any pre-made module to do this. There are a number of projects; the best one I found is

    There are two approaches: discrete circuitry, or a microcontroller. A microcontroller is the "proper" way to do it, and has several advantages, but (a) I don't have time to write the code for the next few days, and (b) either I would have to program a device and send it to you, or you would have to buy a device programmer and program it yourself, or you would have to find someone local who would do that. You would also have to assemble the microcontroller onto a circuit board with a few small components.

    Discrete circuitry is feasible but would require more construction, and it's not simple to get the fade-up and fade-down to be smooth and even.

    In both cases there's a problem with time pressure as well.

    Perhaps you could try a Google search as well. I guess some relevant keywords would be PWM LED controller driver smooth fade-up fade-down fade-out fade.
    OK. Try to find something locally. It needs to produce 12V DC and it should be rated for 1A (1 amp) output current (or more). As well as the appearance, consider the look and length of the lead, and make sure you can get a matching socket for the DC plug.

    Thanks for the extra information. It all makes sense. But I'm not clear on how the sensor will control the light. I don't think a short-distance IR sensor can detect the presence or absence of an object, so it will have to detect the hand, and have a toggle operation, right?
  9. themalloy


    May 1, 2014
    Hi Kris,

    Thanks once again.

    Correct this is the behaviour I am after.
    The control circuit having a few seconds delay would be ideal too.

    I agree, I would like to do this.

    I have 2 - 3 weeks to have the solution.

    Correct it will have to detect the hand in order to trigger the LED's ON and OFF.

    To recap:
    A control circuit with a delay needs to be created when the light is triggered ON or OFF
    A PWM controller for the fade IN and OUT needs to be built.
    They need to be connected to the 12V LED strip lights.
    I can source the power supply.

    Offers to build:
    It appears as though what I thought was at first a simple project has turned into a much larger one.

    I would love to work with a skilled person who would be capable of creating this solution for me.
    If you Private Message me I can supply my Skype details and we can talk about the project and I can answer any questions you may have. I am based in Melbourne Australia but can pay the person for their time and the postage required in order to send me the goods.

    Any solutions that come out of this I will be sure to post back here so that the entire forum benefits from it.

    Kind regards,
  10. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    Nov 28, 2011
    OK. I'm a bit busy for the next few days - I have a project porting some code to a new compiler, and I have an exam for a qualification that I don't really want... So I'll get in touch later in the week.

    How many units do you want made? If it's only one or two, I can build them up on stripboard ( and test them here, then courier them to you. They would have three connectors: 12VDC in (2 pins), motion sensor (3 pins: +12V, 0V and motion signal), and lighting strip. Estimated size around 6x3x1 cm. How does that sound?

    In the meantime I suggest you test out the motion detector to confirm it will reliably detect a child's hand in that area, and won't be affected by the lighting.
  11. themalloy


    May 1, 2014
    Hi Kris,

    That sounds perfect. Building it on strip board is fine and the dimensions are ideal.
    One would be fine for the prototype, maybe 2 just depends on cost.
    I'll then be able to connect the IR switch motion sensor, LED strip lighting and a power supply.
    I'll test the IR switch as soon as it arrives.
    Please private message and i'll give you my delivery address.

    Kind regards,
  12. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    Nov 28, 2011
    Just FYI this is the circuit I'm planning on using for the prototype.


    The motion detector connects to CN1 at the left. This connector has +12V and 0V for use by the motion detector, and the middle pin is the signal from the motion detector, which must swing to +12V when motion is being detected.

    This signal is voltage-shifted from 12V to 4.8V by R1 and R2 and fed into an input on the MCU, U1.

    I have specified a PIC12F675-I/P or a PIC12F629-I/P for U1 because these are readily available locally. They are 8-pin through-hole devices. I had intended to use a PIC10F200 which comes in a tiny SMT 6-pin SOT-23 package, but they're not available locally and are hard to prototype with. If the design ever goes into production, we can switch to a PIC10F200 and save some space and a few cents.

    C1 is a decoupling capacitor across U1's VDD and VSS pins and is required for reliable operation.

    CN4 is a 6-pin in-line connector position that will be used for programming. On a production PCB it could just be a row of holes, or some kind of tiny pin header or socket; whatever is cheapest. I will probably use a 6-pin 0.1" pin strip in the prototype.

    U2 is a 78L05 three-terminal 5V regulator that supplies regulated 5V for U1. C2 and C3 are decoupling capacitors that are required for stability.

    The MCU's output is on pin 5. It drives Q1, an N-channel MOSFET that switches the power supply to the LED strips.

    Q1 is listed as an STP16NF06 because they are available locally, but two more appropriate SMT devices are listed as well; we would use one of those for production with PCBs.

    The LED strips connect between the +12V supply rail and the drain of Q1 with an inductor, L1, in series, and a capacitor, C4, across the LED strip, to reduce sharp transients that can cause radiated interference, and R6 to help the LED strip voltage drop to zero in between pulses.

    If the design goes to production, you may have to perform some kind of electromagnetic compatibility test before it can be sold. I don't know what the legal requirements are in America.

    The 12VDC supply enters on CN3; D1 provides some protection against reverse polarity.

    I will PM you in a day or two.
  13. themalloy


    May 1, 2014
    Perfect Kris,
    Once again much appreciated. I look forward to hearing from you.
  14. themalloy


    May 1, 2014
    Hi Kris and everyone,

    I have hit a speed bump in this project.

    Up until yesterday I was under the impression that the ultrasonic sensor I had purchased:
    Would be able to penetrate its signal through material such as 3 mm thick perspex or other material such as thin wood veneer.

    I have since been told this is not possible.

    The whole idea for the light as a design project is to not have the sensor showing.
    I know things like PIR sensors can work through material however I need a range that is very small (up to 17 cm max)

    Does anyone have any ideas on how I can get around this? Microwave sensor, combination of a few sensors? a totally different sensor?
  15. davenn

    davenn Moderator

    Sep 5, 2009
    Yeah, those are low power ultrasonic TX and RX, great for motion detection or distance measuring up to ~ 10 metres

    I have seen more powerful ultrasonic units available ... try doing some more googling :)

  16. themalloy


    May 1, 2014
    Thanks Dave, I hear Active IR sensors are able to penetrate through material such as 3mm perspex.
    I'm finding it hard to find one with a range of 17cm (adjustable preferably as i'm sure the range will decrease significantly once it passes through the perspex)
  17. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    Nov 28, 2011
    I think your best bet would be to have some tiny holes in your surface. Is it really necessary for part of the lamp that's not normally even visible to be perfectly smooth with no holes or gaps?


    Have a look at - it may give you some ideas.

    Motion sensing should be possible using ultrasonic transducers glued to the back of a thin sheet of wood veneer, especially if it's made from a light wood like balsa. But that ultrasonic range detector is not the best way to detect movement. You should transmit a continuous signal at the ultrasonic frequency, or at least a reasonably long burst, and detect low-frequency signals in the received audio stream. These are caused by movement within the sound path between the transmitter and receiver due to the Doppler effect. It might be possible to use a single ultrasonic transducer. The microcontroller could control this but some extra analogue circuitry would be needed for the receiver.

    Jaycar, who are local here (and probably there) carry an ultrasonic transducer, part number T/R40-16B, catalogue number AU5550:

    It looks like it might be suitable. The data sheet (linked from that page) is not very detailed though. I looked on the manufacturer's web site,, and that part number isn't even listed now. They do have some movement detector (actually, distance measurement) modules but it's not clear what they look like from the front! And I can't find any data sheets on their site.

    You might want to find a larger manufacturer if you intend to produce these in quantity.

    Another possibility might be capacitive sensing using a flat metal electrode either in front or behind the cover. If you draw a diagram of your intended construction, someone might have a suggestion. I think a capacitive sensor might be hard to shield from other effects that would cause variations in detected capacitance.

    Try this Google image search and visit the web pages for anything that looks suitable:

    Either of these options would require some experimentation and development time. In the meantime you might want to bite the bullet and drop the requirement for no visible gaps in the panel.
  18. themalloy


    May 1, 2014
    Hi Kris,

    Thanks for your detailed post. I will continue to experiment using this sensor by drilling some tiny holes to see if the signal will reach through. That is plan B.

    I would also like to continue down the path of hiding the sensor completely.

    I have no problem with the LEDs, power and PWM.
    The issue is I need a sensor that will be placed behind a sheet of 3mm opaque perspex/acrylic. The sensor needs to penetrate through the perspex and have a ~17cm range out the other side of the perspex.
  19. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    Nov 28, 2011
    It would help if you could show a drawing of how you want this to fit together. I'm assuming that the sensor will be inside the bell of the lamp, pointing downwards, so when someone puts their hand under it, to either put something there or take it away, the sensor will detect this movement. That's how I imagine an ultrasonic sensor would work, anyway. Is that what you intend to have?

    In that case, it would also detect if the lamp was moved, because from the sensor's point of view, this would look like something (the shelf) moving underneath the lamp. I don't know of any way to detect movement of any object with a range that's limited to exactly 17 cm.

    A sensor that relies on reflection could have a more controlled range, but the range would be very dependent on the reflectivity of the object. For example, a highly reflective object would be detectable at a much longer distance than a non-reflective object. This is assuming the object is detected by a change in the detected light level.

    You can also use time-of-flight detection, which is essentially how ultrasonic detection works. The trouble is, the time of flight is tiny for light (which travels around 300M metres/second) and this requires high-tech circuitry to measure it (check out the prices of laser tape measures). Conversely, time-of-flight for ultrasonic (sound) is slow enough to measure, but not very directional.

    I don't really have much experience here. DOES ANYONE ELSE have any advice or suggestions for a good way to detect the presence of a moving human hand underneath a lamp?
  20. BobK


    Jan 5, 2010
    Any chance you could use something that passes infrared but looks opaque to the eye because it blocks visible light? Sort of like the front of a TV remote, which looks black but actually passes IR.

Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day