Hack Your LED Strip With a Motion Sensor and Timer




I find that the measure of a good Instructable is the ideas that it inspires, which is why I enjoyed Liam.great98's Instructable titled "Give Your Bed Underglow!" I never would have thought of adding an LED strip to the bottom of a bed otherwise, and I immediately wanted to do this for my kids.

I wanted to go a bit beyond what Liam.great98 did and add the ability to have the lights turn on when needed and off again after a period of inactivity, so I decided to try my hand at hacking the LED strip to do just that. This instructable will show you how I went about hacking my LED strip to add a microcontroller and motion sensor. Hopefully the ideas you find here will serve as a launching point for your own ideas and improvements.

Step 1: Theory

(This step is a discussion of my approach to hacking the LED strip, and may not necessarily be well described. If you just want to get on with the instructions already, feel free to skip to the next step.)

The LED strip I purchased (found here: http://www.banggood.com/Wholesale-5M-RGB-3528-LED-...) came with an LED controller and remote control, which I think is quite common.

The idea is to be able to add a microcontroller that can control the power to the LED strip (turn it on and off as needed), without losing the ability to control the color and pattern with the remote control. There were two options, as I saw it:

  1. Build an entirely new control circuit.

    This would require integrating the remote control receiver into the new microcontroller, reverse engineering the remote protocol, adding MOSFETs to control power to each of the LED channels (and, probably, a MOSFET control chip), and programming the light values and patterns into the microcontroller.

    However, that's quite a lot of work and a lot of additional electronic components. To be honest, and let's be clear about this, I'm far, far too lazy to do all that work, which leaves option number...
  2. Wire the microcontroller into the existing circuitry.

    This is the approach I took for this Instructable. and will be described below.

Somehow the circuit needs to be modified to allow the microcontroller to control the power supplied to the logic portion of the LED controller circuit board.

A quick look at the LED controller circuit board shows that there are two black ICs. The upper IC in the pictures is the brains of the controller. It changes the LED color, does pulse-width modulation (PWM), and controls the light patterns. I'm guessing that the lower IC is a MOSFET control chip, which turns power on and off to each of the LED power lines (I could be wrong about this, however). There's also a ground plane (highlighted red in the third picture), a +12 volt power rail, and a +4.7 volt power rail (highlighted in blue). There are several potential solder points (highlighted in yellow).

The LED controller accepts commands from the remote control, allowing the LED colors to be set and for different display patterns to be selected. The controller is able to remember the LED settings when power is removed and reapplied, which will be very helpful.

I measured the current being drawn by the two ICs at about 1 mA, which is well within the current sourcing abilities of most microcontrollers, so a transistor or MOSFET will not be needed and the ICs can be powered directly from the microprocessor. All that is required, then, is to disconnect the two ICs from the +4.7 volt power rail (by cutting the circuit board trace at the black line), tie the microcontroller to +4.7 volts and ground, and connect one of the microcontroller pins to the power pins of the two ICs on the LED controller circuit, so that the microcontroller can power the ICs at will.

A simple and cheap PIR motion sensor can be easily connected to the microcontroller to detect motion, and the microcontroller can easily be programmed to timeout after a specific period of time.

Seems simple enough!

Step 2: Parts and Tools

Here's a list of what I used to do my hack. Note that you can use substitutions for most of the parts listed here, but this Instructable will be written specifically with these parts in mind. I will try to provide enough information that you can customize the steps, if needed.

1) An LED strip.
I used the same RGB LED strip suggested in the Liam.great98's Instructable, which is cheap and works great for this project. It can be found here:

This strip comes with a controller for the strip and a remote control to change the color and light pattern.

2) Power Supply.
Check the requirements for your LED strip. The one I'm using called for a 12 volt power supply capable of supplying 2 amps of current for the 5 meter strip. I found a suitable power adapter at a local thrift store for $3, but you might have one already lying around.

3) A PIR Motion Sensor.
These are pretty easy to find. I found a good deal on a pack of 10 on eBay. You can also get them at Fry's Electronics, Radio Shack, or various places online (like this one from SparkFun:

https://www.sparkfun.com/products/8630). This should have three pins, one for power (3.3-5 volts), one for ground, and an output pin that goes high when motion is detected.

Some good information on using PIR sensors can be found here: http://learn.adafruit.com/pir-passive-infrared-pro...

4) An Attiny85 microprocessor and a Programmer.
This will be used to provide the brains of the hack. It will provide power to the LED strip controller when motion is detected, and remove it when there has been no movement for a period of time. I used an Attiny85, but an Attiny45 should work just as well as long as it's physically small enough to fit inside the existing LED controller case. You can certainly use another brand of microcontroller (ie. a PIC), but you'll have to supply your own code.

You'll also need to have a way to program the microcontroller. I use one that I built, and there are many Instructables that can show you how to make your own. I will provide both a .hex file to directly program the Attiny85, and source code, if needed.

5) Various electronic parts (not shown)
The values of these parts do not have to be exact, and some may not even really be needed. Here's what I used:
1 4.7 kΩ resistor.
1 10uF capacitor.
1 100uF capacitor.
1 3-pin SIP socket to plug into the PIR sensor (like this from Sparkfun: https://www.sparkfun.com/products/115).
1 DIP socket to allow the microprocessor to be removed for reprogramming, if needed (optional but recommended).
1 prototype board (I got a good deal on some 5x7 cm prototype boards on eBay similar to these from Radio Shack: http://www.radioshack.com/product/index.jsp?produ...
3 small lengths of wire (I used some telephone wire I had on hand).

6) Soldering Iron, Solder, and a Steady Hand (not shown)
Yes, this project involves soldering. There's not too much of it, but it is a bit detailed, so you should have some experience with it.

7) A drill and a 1/16" drill bit (not shown)
I used these to make wire holes in the PCB, but you could conceivably do without.

Step 3: Open Up the Controller

The first step is to get access to the LED controller circuit board. I was able to easily pop the bottom off of the control box with a flat head screwdriver.


Step 4: Modify the Circuit Board

So, the controller is designed to provide power to the electronics constantly. In order to be able to turn the strip on and off with the microcontroller, some modifications need to be made to the circuit board.

First, the two ICs need to be disconnected from the +4.7 volt power rail. This can be done by (carefully!) using a sharp knife to cut the circuit board trace as indicated by the black line in the picture.

Second, wires need to be added to circuit board to allow power from the board to be used to power the added microcontroller and to allow the microcontroller to supply power to the two ICs as needed. The three convenient solder points have been highlighted in yellow in the picture.

The black dots in the picture show where I drilled 1/16" holes in the circuit board to run the wires through. I did this because I felt it would make the wires more secure, but it is not strictly necessary, if you're careful about not pulling your wires too much.

Step 5: Add Wires

This is, probably, the trickiest part of this hack and, really, it's not that bad.

Wires need to be soldered to the solder points identified in the previous step. The wires should be cut to about 3 inches or so, and then stripped on one end and soldered as shown. Take it easy here and be careful not to get solder anywhere it's not supposed to be. If you take your time here, you shouldn't have a problem.

I used hot glue to secure the wires into place a bit more securely (shown in the third picture), and I would advise you to do the same, if you can.

You'll also want to label the wires somehow to make them easier to identify. I will be referring to them as "Power" (the wire supplying +4.8 volts from the circuit board to the added microcontroller), "Control" (the wire supplying power from the microcontroller to the IC chips on the board), and "Ground".

Step 6: Program the Microcontroller

The .hex file for the Attiny85 is included below. This file is my compiled program. As long as you're using an Attiny85, are using the same pins as shown in the circuit diagram, you should be able to use it to program the microcontroller and be good to go. Feel free to skip to the next step if this is the case.

However, if you need to recompile the code for a different microprocessor, change the pins around, alter the timeout period, or make other modifications, you'll need the .ino file, also attached.

My preferred method for coding for the Attiny85 at the moment is to use the Arduino platform. You don't need to own an Arduino board, but to use the attached code, you will need to download and install the Arduino IDE from here: www.arduino.cc.

You can find instructions for setting up the Arduino IDE for the Attiny85 (and other Attiny microprocessors) here: http://highlowtech.org/?p=1695.

The actual programming instructions are beyond the scope of this Instructable. A quick look around this site should provide a number of excellent Instructables. You can build your own USB programmer using this Instructable: https://www.instructables.com/id/VUSBTiny-AVR-SPI-P..., or build a programming shield for the Arduino board following this Instructable: https://www.instructables.com/id/Stripboard-Arduino.... There are probably many other ways to do it as well.

I've attempted to comment the code to make it clear what it does and where to change things. The pins and power-off time period can be changed at the top of the file.

Step 7: Build the Circuit

The microcontroller circuit diagram is shown above. I would strongly recommend breadboarding it before soldering it to make sure everything is wired up correctly.

Note that I'm using a DIP socket so the the Attiny85 can be removed from the circuit for reprogramming. I highly recommend doing this because it will prevent the microcontroller from being damaged by the soldering process and will enable you to make changes in the future, but it is not strictly necessary.

Note also that I've terminated the three wires going to the PIR sensor with a 3 position female header that matches the three pins on the sensor. This makes it possible to connect and disconnect the sensor as needed, but could potentially be left out if you just want to solder the wires directly to the sensor instead. Make sure to match the wires to the correct pins!

There should be plenty of room in the LED control box to fit the additional circuit board, but the prototype board will probably need to be cut down to fit.

You'll want to test the circuit before moving on from this step. It may be more convenient to reprogram the microcontroller to power off after a shorter amount of time in order to make sure the timer code is working correctly.

Step 8: Repackage

At this point, everything is nearly ready to be repackaged in the original case.

All that's left is to cut a slot for the wires for the PIR motion sensor. Use a sharp knife,cut away from yourself, and be careful!

Step 9: Attach the PIR Sensor

At this point, you can attach the PIR sensor by either plugging it into the header or soldering it to the wires. Again, make sure to match the wires to the correct pins.

I attached the sensor directly to the LED controller case, but you can leave it hanging loose if it's easier.

Step 10: Enjoy!

Honestly, what you do at this point is entirely up to you. I followed Liam.great98's lead and installed the LED strip under my daughter's bed. See his Instructable (here: https://www.instructables.com/id/Give-Your-Bed-Unde...) for more instructions on how to go about it.

Enjoy your hacked LED strip. I would love to see what uses you come up for it in the comments below!




  • Fandom Contest

    Fandom Contest
  • Pets Challenge

    Pets Challenge
  • Frozen Treats Challenge

    Frozen Treats Challenge

21 Discussions


Question 1 year ago on Introduction

Im wanting to have different controllers control several different strips. I am wiring leds along the base of my walls in all the egress areas of my home. I want them to come on at dark with a photocell, but only the white and only half power so they are dim. When someone steps into those paths, a PIR motion sensor will take over and bring that particular section to full power and to a bright setting. After the PIR sensor does not detect anymore, they return to a dim state again. These are RGBW strips, with only white being used after dark. I would also like to control the colors at will with a remote, just in case I want the entire house to dance. This is what I have come up with as far as a route for the wires. Any input, even your crazy, would be much appreciated. Thanks in advance for your time.


3 years ago

Great idea! Looking for exactly this for an art installation.

Three Questions: What were your total project costs (estimated)?

How long did you set the lights to stay on?

How sensitive is the detector? Did it go off at any little sign of movement?


2 replies

Reply 3 years ago

1) I'm guessing it would cost about $30-40 depending on the deals you find and what kind of power supply you use. I used a cheap wall wart I had lying around.

2) The code is configured to stay on for 30 minutes before shutting back off. this is easily changed if you program the microcontroller using the code (.ino) file.

3) It's pretty sensitive. I can't walk into my daughter's room without the lights under her bed turning on.


Reply 2 years ago

any chance you could help us out with this. please.


2 years ago

Hi Brad, my controllers are slightly different to the one you show, but I guess they work on the same principal. in your pics you show where to cut the strip on the board but when looking at the other pics further down there is no cut on the board. reason I'm asking is because I've already fried 2 controllers. I've connected everything up as described and programmed the attiny85, but when I power it up the transistors start to smoke. the only thing I can see different is the controller does not have all the smd components yours has. any ideas would help.. regards bill


2 years ago

I want this to incorporate into my Kitchen underbench lighting . Turn on if dark and movement detected so I have the dak detector worked out too.

The other bit I want to incorporate is to synthesise the lights to music from a radio chip so I am endevouring to put these all together .



2 years ago


Great instructable. I will use it to (hopefully) light up a flight of stairs.

I've checked the ICs on my RGB controller and it seems to me the "brains of the controller" is just an EEPROM. Not that this changes much.


2 years ago

Hi Brad, I am going to try building your project for an art light installation. The ceiling height is 17 feet, so I need a PIR sensor with more range. Any suggestions?

Also, I will be connecting many LED strips together to make a cube. Any tips on managing the voltage of several strips joined together?



2 years ago

Great stuff man.. In the planning stages of building led step lighting with multiple sensors as triggers.. Thanks for the ideas..


3 years ago

Hi, I like your idea / hack. I have one of these that I hooked up to a light switch (instead of a PIR) and there are 2 things that I don't like about it.

1) When I turn the light switch on (supplying 120V to the power supply) there is about a 2 second delay before the LED's come on, and

2) If I leave the light switch off for 2 or 3 days and turn it on, it frequently does not remember the color and brightness where I left it.

My question to you is for the ones that you made up - do you have either of those issues with the PIR?

This may be a perfect solution for me.


3 years ago

To the point...I know nothing about this so your instructable looks like mumble jumble to me. How hard would it be for a beginner to complete this successfully? I'm really wanting to run an LED strip under my bathroom sink vanity. I'd like to run it off of batteries and have a motion detector connected to it. It really doesn't sound like it would be difficult but looking through your directions it may be over my head. Thanks for the idea.


3 years ago

I'll be making at least one of these as soon as I get a break in the homework!

There are two stairways in my house that are dangerous because of poorly lighting and light switches. This could make them safe quickly and easily.

I've added it to my "Practical to Make" collection. Unfortunately, it's only the third 'ible in there, so I can't make it public yet.

1 reply

Reply 3 years ago

What a great use! I hope it works out well for you. If you get a chance, I would love to see the finished product.

I love the idea of a "practical to make" collection. There are so many instructables on this site that I would love to do, but I don't have access to a fully stocked professional workshop, 10gW cutting laser, and industrial factory, so many are out of my reach. I'm flattered to have my Instructable on there. Thank you!


4 years ago

Exactly what I'm searching for and can't believe nobody is making them ready to go ??

Money to be made here for someone If anyone feels they could make these easily for me I'm happy to pay parts and labour UK Kent area


4 years ago on Introduction

Question, can this be modified to have two motion sensors? I would like to do this on my stairs (L-shape with a 90 degree landing in the middle). That way on either end of the stairs the lights would be triggered? Thanks in advance.

1 reply

Reply 4 years ago on Introduction

Yes! It wouldn't be difficult at all. Just connect the output pin of the second motion sensor to another I/O pin on the microcontroller (pin 5 would work well). You'll have to modify the code to check for input from both sensors, but that wouldn't be hard at all.


4 years ago on Introduction

Not a coloured strip, but I'm looking for something to switch a stair-light LED strip on and off, the PIR and processor solution is just what I'm looking for! Thanks for sharing!


5 years ago

This is a great idea! I love it!