Picture of Motion Activated AC Switch

I hate Christmas tree lights.

Well not really, I just don't enjoy having to climb under the tree every time I want to plug in or unplug the lights. In the interest of saving my sanity, I decided to build a motion activated switch that can power the lights for me. It has an integrated adjustable timer so they will stay on for as long or as short as I want. Here's a video showing the final test on the fish tank light.

Remove these adsRemove these ads by Signing Up

Step 1: Safety and the parts and tools list

Picture of Safety and the parts and tools list

First, a word about safety. We will be working directly with AC mains voltage, so BE EXTREMELY CAREFUL!! Make sure that any time you are testing the circuit, you have your work space clear and anyone around you is aware of the danger. Also, don't burn yourself with the soldering iron. It is hot. Don't be that person.

I salvage what I need/want from whatever device I can get my hands on. Most parts are still useful as long as you take care in how you remove them from the original board. That being said, none of the parts are expensive, so it shouldn't be hard to come across them if need be. Also, many times the exact part is not absolutely required, just something that is compatible, e.g. a 2N2222 NPN BJT instead of the 2N3904 listed.

The Parts:

- 1 power transformer. Any transformer that has a step down factor of 10 will work here. We want an output of about 12-15VAC, but if your outlet supplies 220VAC, it will still work.

- 1 board mounted outlet. You can find these on the back of DVD players, home theater systems, and VCRs.

- 1 rubber grommet. This one came with the AC power cable attached to the transformer and is used to secure the cable to the housing. Very handy if you can get one.

- AC power cable. We don't need a grounded cable here, so 2 wires will do fine.

- board pins as needed/desired for connecting AC lines. You can also solder directly to the copper pads but it may not be as secure.

- 1 board mounted fuse holder. I used a 5X20mm fuse.

- 1 fuse rated for slightly less than the relay max current rating. Mine is a 250VAC 4A, slow blow.

- 1 555 timer IC with 8-pin socket. Any brand will work.

- 1 7809 +9VDC voltage regulator. You can use whatever regulator you have so long as it matches the DC input rating on your relay switch. You also don't want a 7909 regulator as it will provide -9VDC, which you don't want.

- 1 Parallax PIR sensor. Found mine at radioshack for about $10.

- 1 2N3904 bipolar junction transistor, or BJT. Any NPN BJT should work here.

- 4 1N4001 rectifying diodes. You can also get a bridge rectifier if you want, since that is what we are going to build.

- 3 capacitors: 1 0.01uF (103) ceramic disc; 1 470uF electrolytic; 1 large electrolytic. I used a 1000uF. The large electrolytic will be used to run the timer, so the bigger it is, the longer your max time can be.

- 4 resistors: 2 1k; 1 4.7k; 1 10k

- 1 potentiometer. Mine is a 4 megaOhm pot. This pot will allow for adjusting the timer. With the 1000uF cap, mine will run for about 2.5 hours.

- 1 9VDC relay. The coil voltage should match the regulator voltage. The switch portion of the relay needs to have a decently high current rating since we will be running AC current directly through here to the device we want to power. Mine is rated for 250VAC 5A.

- 1 LED and 1k resistor (optional, LED not pictured). Used mostly for testing, I didn't keep it for the final build.

- screws, wires, heat shrink, glue as needed

- plastic project enclosure

- printed PCB

The Tools:

- Digilent Analog Discovery. Highly recommended as it will allow you to verify circuit function using the built in oscilloscope.

- soldering iron and solder. I use a 40W for just about everything.

- wire cutter/stripper, pliers, hobby knife, screwdriver

- breadboard for testing

- digital multimeter

- saw and/or rotary tool (not pictured)

1-40 of 42Next »

Sorry for maybe sounding a little bit stupid I'm kinda new to this, although I get a big voltage drop across the relay, I get like 2 Volts, what might be the problem ?

brmarcum (author)  darius.mackun1 month ago

Don't apologize for learning.

Where are you getting 2V? Look back at the schematic and use that as a reference for me to visualize.

Thank you kind sir for your reply. Across the coil of the relay I get 2 V , in the step 7 schematic, out from where it's written "to 555 pin3 (output)" to "GND". If I test those two ends with my multimeter it shows 2V. Plus I'm using 12V relay, cause the shop didn't have 9V relays, and I'm using 220V AC conversion to 12V DC, I think that it should be alright anyways because my PIR has max voltage of 15V and 555 as I read in the datasheet can handle until 15V too

brmarcum (author)  darius.mackun1 month ago

A few thoughts come to mind:

1) check the voltage coming from the 555 pin 3 to GND without the relay connected. It should be almost the same as your input voltage to the 555. If it's not, the problem is most likely not the relay.

2) Are you sure you have the relay coil terminals connected between the 555 and GND and not the relay switch terminals?

3) What is the step-down factor of your transformer? You input 220VAC, what AC voltage do you get out of the other side of the windings, before you attach the bridge rectifier? You want output to be about 1/10 of input.

4) What voltage regulator are you using to power the 555?

5) Which PIR sensor are you using? I'm highly intrigued that your PIR has a max voltage of 15V. Are you sure? Most are meant to be used with microcontrollers (ChipKIT or Arduino), so a source voltage of 3-6VDC is very common.

1) just did it and having issue of 0V from pin3 to GND = 0V
2)Yep, I'm pretty sure

At the moment can answer 3 , 4 , 5 , I dissassembled the whole scheme, going to try to assemble again

3) I'm using "APV-12-12" to convert it for me, it converts 220V AC to DC 12V.

4) I'm using 7809 voltage regulator
5) I'm using HC-SR501

Btw since it is my first time doing this on breadboard, so I might've made some mistakes, I should probably just try to solder it all together and see what happens.

brmarcum (author)  darius.mackun1 month ago

Bad idea. Never solder a circuit without knowing for sure that it works. It just creates headaches. That's why we have breadboards.

Sasando_Rote2 months ago

I am new to this, Can someone make a design of this project like this one >

brmarcum (author)  DewlanceHosting2 months ago

What are you asking? The design is in the image, so I'm confused.

rameezkoya0077 months ago
how could I adjust the working time of the circuit to 15-20 minutes?
brmarcum (author)  rameezkoya0077 months ago
You can get anywhere from <1 minute to over 2 hours with the schematic as is. Look at the schematic to Step 5. The potentiometer (P1) and the 1000uF cap (C3) determine the timing. Changing either one for a component with a smaller value will shorten the time. The large 4M pot makes getting a precise time difficult since a small change on the pot will result in a large change in the timer output, but you can get 15-20 minutes as is. You just have to test different values to get it where you want it.
rameezkoya0077 months ago
I have a doubt.
Help me please.
can I connect two PIR sensor in the circuit ?.
I yes ,how?
If it's possible I could place those sensors on the the either sides of my garden pavement.
brmarcum (author)  rameezkoya0077 months ago
Yes absolutely. The best way I can think of to do it is to pass the two inputs from the two PIR sensors through an OR gate on an IC (like this one). That way, when either sensor triggers, the timer starts and the lights go on.
bcraun9 months ago

Just curious; what is the max on time when using the 4M ohm adjustable resistor? Is the point to keep the PIR in re-trigger mode constantly with movement in the room, or to maintain the on state using the timer?


brmarcum (author)  bcraun9 months ago
In theory the timer could run forever. The threshold pin on the 555 requires a certain voltage level to allow the output pin to go high. A larger cap/pot combo will give a longer time. This particular build ran for about 2.5 hours. I have another project I built that would run for about 4 hours.
Unfortunately the timer isn't able to reset to zero every time it triggers. Once it triggers, it's on and will run until the cap runs out.
bcraun brmarcum9 months ago
Gotcha. So, aside from the RC combination, the theory is that once the PIR triggers the circuit, it's active for around 2.5 hours. At that point, any movement in the room would re-trigger for another 2.5 hours...and so on? So the assumption is that someone will move at least every 2.5 hours to keep the lights on?
brmarcum (author)  bcraun9 months ago
Yes. Once it triggers, it ignores all subsequent signals from the PIR until the cap runs out, and then resets back to zero. It's not ideal, but it will work
DBoulanger9 months ago

After re-reading your intro, which described your main objective, with pretty much the same parts and a few more, you could potentially consider creating some sort of toggling circuit, with the 555 and a LDR, which could be controlled via a small laser light, like the ones we have on some keychains.

If you want, you can also go for an IR led approach, like the ones in TV sets, DVD players, etc..., allowing you to toggle the circuit with your current TV remote control, or mostly any remote control for that matter.

In either case, strategic positionning of the LDR or IR led is mandatory to prevent false triggering by external lighting, naturally.

Finally, you could also consider a RF switch. The beauty of that little beast is that it can be completely hidden and you can even toggle the switch without having to aim at the receiver. Plus, it isn't affected by the light, which could be considered as an advantage.

Anyhow, you have plenty of choices, so just let your imagination guide you !

Have fun !

brmarcum (author)  DBoulanger9 months ago
I'm really intrigued by those ideas. LEDs can actually be used as phototransistors as well. Forrest Mimms did a lot of pioneering work in that area many years ago.
matsk9 months ago

I love this easy electronic project with a practical usage!
And my 20 cent improvments would be to change the PIR to a PIR with adjustable sensitivity and delay like or equal.

That would make the 555 obsolete.

brmarcum (author)  matsk9 months ago
Thank you for your advice. I have no experience with that particular sensor, but I have been warned to be wary of really low price PIRs. If it is working for you, that's great. I may try it with something else.
matsk brmarcum9 months ago

The PIR's i have bougth on ebay have two different pin layout. I have bougth PIR's from five different seller on ebay and I haven't found "bad quality". The schematic is mostly the same a D203 sensor and a LM324 OP amp or equal.

DBoulanger9 months ago

Nicely done. You obviously have good soldering skills. Personally, I kind of dislike those 30-40-50W soldering irons. I treated myself and got an Hakko FX888D soldering station. It's a real gem for the electronic enthousiast that I am.

Concerning the PIR sensor, it must be understood that this little beast is actually activated by a variation of heat, not really motion as some of us are lead to believe with the advertisements.

The PIR is a "Passive Infrared sensor" device that reacts to small variations of heat close to it (within 10 feet or so). I discovered it when I installed my so called "motion detector" at the top portion of my garage door, with the sensor pointing down towards the floor.

When my dogs are going outside or coming back, the sensor activates, letting me know with flashing leds that something/someone crossed the doorstep.

However, when the door is left opened, the sensor also reacts to air drafts. If there is some air flow, of warmer or cooler air than the air actually being "monitored", the sensor may activate despite there is no human / animal movement / motion.

Globally, that PIR sensor takes an infrared snapshot of the area it's pointing to and if there is any sufficient heat change detected, would it be because of a human, an animal or simply air flow, the device will trigger.

Nothing really scientific, but might be interesting to know, either to adjust accordingly and prevent false triggering, or simply incorporate this "feature" in one of your future project.


brmarcum (author)  DBoulanger9 months ago
Thank you for the compliment and for explaining how PIR sensors work. You are absolutely correct and this project could be a bit tricky in a home with pets. Most PIRs come with sensitivity adjustments, but they are not all created equal.
ASCAS made it!9 months ago

Love it! That PIR motion sensing is quite useful. I added your PIR motion sensing idea to my DIY Home Automation Box. Since there's no more room for the PIR, I hacked my dollar store Motion-Door chime and added a $3 RF module. I must say, it makes life more convenient ! Thanks for the wonderful idea! Cheers! :D

brmarcum (author)  ASCAS9 months ago
Very glad to hear that you were able to improve your own project. Do you have a link to it?
witkowski89 months ago

Pro instructions, great

tsaltzman9 months ago

I really like your idea and what you did but if you had a switch outlet in the room where your xmas tree is you could just replace the wall switch with a motion one and put a time between the wall outlet and xmas tree...but making things is so much better. ;)

brmarcum (author)  tsaltzman9 months ago
Well my wife wants the tree on the other side of the room from that switch. So I get to have fun building.
transistor29 months ago
do you know how to switch from DC current to ac ?
brmarcum (author)  transistor29 months ago

DC to AC inversion is not something I've used with any project so far, though I do have a current project that will require it, so I'm doing my research into that as well. There are a few methods I've found so far: using a 555 timer IC and some transistors, using only transistors, or using a relay. All three look promising, it just depends on the requirements for the circuit you want to build and the space/weight considerations you have available and/or want to take up.

gada8889 months ago

Thanks for your info.l love the 'parts kit'and 'discovery',but i am not in the discount bundle is not available to me.who can help me to get them as student or academic special i pay him extra through paypal.

gada8889 months ago

Thanks for your feedback.i am thinking of taking one.Do you use simulators to assist you design? Electronics calculation is also my headache.What book you find is most useful in this field.I am a newbie need advice.

brmarcum (author)  gada8889 months ago

I have found simulators to be very useful in very specific applications, though not in the large majority of the time. I usually just build and go with it, but that comes with some experience.

As far as electronics calculations go, the best way to get it is to just do it. That being said, I recommend This is one of the better (but not only) online resources for learning analog electronics. It's laid out like a university level EE course, starting at the basics and going through much more advanced concepts.

I also recommend Click on "Browse Individual Projects" on the left, then on "Analog" in the green box toward the top. The projects are pretty focused on gaining product knowledge, but on the right hand side you will see several buttons for related topics, like "voltage" or "current". Click on those to get a more general idea of those concepts. This site will eventually contain a similar course layout as the previous site, but that is still being developed.

As far as printed books go, as soon as I get mine back from my friend, I will let you know.

padbravo9 months ago

This is one of the best explained instructables that I've found on this site (year from now).
And that is because it explains not only the construction, but the theory behind each steep, and in electronics, this is not that easy.

link to find this device? (the analog discovery scope)

brmarcum (author)  padbravo9 months ago
Wow, thank you. That's very kind.
The Discovery is listed as the first tool in step one. The name is highlighted, which is a link to the product page.
gada8889 months ago

Very nice informative the way,is Digilent analog discovery a worthwhile investment. I own a traditional bulky analog oscilloscope,but i want on e better or carry more functions.

brmarcum (author)  gada8889 months ago
I've been using the analog discovery for several months, both for school and work. In the interest of full disclosure, I am an intern at Digilent, but I was using it before that and have found it to be a remarkable piece of equipment. It easily takes the place of thousands of dollars of benchtop equipment, like an o-scope, spectrum analyzer, power supply, & logic analyzer. It does have limitations as it is powered by USB, but for everything I've done, it has performed beautifully. If you do need more power or scope channels than the discovery can provide, check out the Electronic Explorer Board, also from Digilent.
tl;dr: yes, definitely worth it.
1-40 of 42Next »