Motion Activated AC Switch




About: I've always loved to figure out how things work, so hacking and making just fits for me. I'm a husband, a father, an EOD technician with the WA Army National Guard, an automation engineer at Schweitzer Engin...

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.


Step 1: 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)

Step 2: Design

The basic idea is that we first step down 120VAC (or 220VAC) down by a factor of ten. We then rectify and smooth that to get rid of the negative part of the wave, which allows us to then regulate it to a usable, stable 9VDC voltage. The PIR can't use 9VDC though, so we will be dividing it down to 4.5VDC just for that part.

Step 3: Testing

Get yourself a breadboard, and some wires or jumpers, for testing if you don't already have one. I use it every time I build. You don't want to be soldering and cutting and find out you did it all wrong. Don't say I didn't warn you.

Each subsystem is broken off into smaller bits to make building and testing easier. Make sure each subsystem works before attaching it all together as one big circuit. It makes debugging way easier and less frustrating.

Step 4: AC/DC Conversion

Again, we are stepping down AC mains voltage by a factor of 10. The 4 diodes are configured as a bridge rectifier. Make sure to get the connections correct here. It can be very confusing when putting it on a board. Or get a bridge rectifier as a discrete part. The 470uF cap keeps the voltage high enough to be used by the regulator. You need the input to the regulator to stay higher than it's rated output or you won't get a stable output. With this setup, I could use a 7812 regulator for +12VDC, but just barely and no more than that.

As mentioned before, be very careful when testing this sub-circuit. Since the output here is 9VDC, you can use a 9V battery to test subsequent systems without exposing yourself to live AC.

Step 5: Timer Circuit

I found the original schematic for this circuit in Forrest M. Mims' book Basic Electronics: Transistors and Integrated Circuits, page 91. A wonderful book by a fantastic author. I've used this circuit several times before and will again. I modified it by changing the pot/cap pair to meet my needs and removing the buzzer. The original circuit also has a push button momentary switch between the trigger (pin 2) and ground to activate it. I've changed it to use the output from the PIR sensor, but the the 555 requires a logical low signal to trigger and the PIR outputs a logical high. That problem is solved by using the NPN BJT. More on that later. Just know that if you want to use this circuit elsewhere, the trigger must be a low signal. The 4.7k resistor acts as a pull-up resistor to keep the signal high when no signal is coming from the PIR sensor.

You'll probably notice that adjusting the timer value is not very precise. Using larger value components makes it so that the tiniest change on the pot makes a big difference in time. It's the nature of analog circuits, and I think it's part of the appeal for me. If you want exact precision, I recommend a chipKIT microprocessor board from Digilent Inc.

Step 6: The PIR Sensor

Really simple connections with this part, though the BJT is easy to switch around backwards. The PIR is designed to be used primarily with microprocessors, like the Digilent chipKIT Uno32, so it can only handle 3-6VDC input, so the two 1k resistors form the voltage divider we need to drop the 9VDC supply down to 4.5VDC.

Step 7: The Relay and AC Passthrough

Easy connections here too, though we are using AC voltage again when testing. The AC outlet, with a 4A fuse connected, will run a fair bit of power through it. I only plan on using this project where I don't need very much power, e.g. LED Christmas lights instead of incandescent. Keep your power needs and circuit limitations in mind as you design and use your own version.

Step 8: Building and Finishing

Be aware of space limitations inside your enclosure as you are placing and soldering the parts to the PCB. The AC outlet should have screw holes on the side to securely mount it to the case, so plan for that as well. You also don't want anything to short out inside after it's closed, so keep an eye out for exposed contacts and such.

You may very well make a mistake, no matter how hard you try. I got the outer leads on the BJT switched around and it wouldn't do anything for me. I went through the whole thing, testing voltages until I found the problem, de-soldered the wrong connections and then re-soldered correctly. I also forgot to feed the PIR wires through the case before soldering to the board.

I designed the whole thing to sit underneath my Christmas tree skirt, so the PIR sensor will need to be placed up into the tree. I have a length of cable attaching it to the box, which saves space inside, but may require a design change should I want to put the PIR inside in another application.

Please don't hesitate to ask questions, either below in the comments or PM. Have fun building!



  • Colors of the Rainbow Contest

    Colors of the Rainbow Contest
  • IoT Challenge

    IoT Challenge
  • Woodworking Contest

    Woodworking Contest

48 Discussions


1 year ago

Would you have any idea on how to get the effects I'm looking for it or could you point me in the right direction I saw a hall effect circuit that does basically what I need it to do but I guess you have to have a magnet in your hand while waving is there some way I could maybe have two coils and cause them to Arc maybe something like that?


1 year ago

hi ive been trying to figure out how to build a close range motion on/ motion off switch for a power supply so that i wave my hand over the sensor to turn it on and it will stay on til i wave my hand over it again to turn it off. is that what this circuit is meant to or could do? here is an example:

2 replies

Reply 1 year ago

No, this circuit will not turn off when you wave your hand in front of it. This circuit will turn on with motion and then stay on for a set amount of time. All motion will be ignored once it has turned on, but once it turns off you can move in front of it to turn it on again.


Reply 1 year ago

I found what I was looking for i think

yogesh thakare

3 years ago

what if i use an old mobile charger adapter to step down from 220v to 5v and remaining ciruit same ,will i have to change anything else or replace any component?

thank you


4 years 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.

2 replies

Reply 4 years 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.


Reply 3 years ago

A PIR sensor senses a human or animal right ?

Then how could i modify this circuit to sense my car or bike as well ?


Reply 4 years ago on Introduction

There may be a couple of reasons for it.

1) Bad 555. Swap it with a new one. Probably not this since 555s are pretty tough little ICs.

2) Circuit was built wrong. This is much more likely. No offense intended, I get stuff crossed all the time. Double check everything, and if it still doesn't work, rip it apart and start over. This is why we test everything on a breadboard first.

3) Bad component. A good DMM will allow you to check just about any passive component except for inductors, and then you can check the inductor's internal resistance (generally if the resistance is within spec, it's still good, though may not be). Check capacitors C2 and C3. The 555 may not be able to function properly because one or both may be bad.

That's what comes to mind. Keep me posted.


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 ?

7 replies

Reply 4 years ago on Introduction

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.


Reply 4 years ago on Introduction

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


Reply 4 years ago on Introduction

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.


Reply 4 years ago on Introduction

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.


Reply 4 years ago on Introduction

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

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