Now when I walk into my room (or my cat :) my lights automatically pop on for me! In this project I'm going to show you how to for under $5 hook up a motion sensor to you ceiling fixture! This is what happens. When the motion sensor senses motion it sends a HIGH signal to microcontroller. The microcontroller then turns on the light and starts a 5 minute countdown. Everytime the motion sensor senses motion it resets the 5 minute timer. So say I walk in my room at 5:30 and immediately walk out. At 5:35 the light will turn off. Later in the day my cat walks in at 6:00, then walks out. Three minutes later, she sees a mouse in my room, so she runs back in at 6:03, but realizing that the mouse if just a play mouse, runs back out. At 6:03 The timer is reset and the light won't go off for another 5 minutes (6:08).
The second mode of this project just keeps the light on as long as the circuit has power. So if you sleeping at night and want the fan to stay on all night you can switch it to that.
Just think, next time you leave the house and forget to turn the light off you can have the satisfaction that the light will automatically turn off in 5 minutes! This whole project can be built for about 5 dollars and takes quite a bit of time but is very worth it in the end! Watch the video, make the project, and vote and share!
Of course you can change how long the light stays on if you want. Change it to 10 minutes if you'd like! Just remember you have to convert however minutes you want the light on into milliseconds!
Step 1: Ingredients
Link to code http://www.mediafire.com/view/xgnd2ba71hqur5d/DIYMotionsensor.ino
I would explain it but I really don't know how to so!
Thanks to lewisb42 for helping me out with the resetting timer.
• ATtiny programming shield or 10 uf capacitor
• 8 DIP socket
• PIR motion sensor
• Relay- the kind that comes on a pcb with a protection diode and transistor
• SPDT switch (with an off position)
• IC circuit perf board
• 1/8 or 1/4 inch male and female audio jacks (mono is easier)
• Breadboard and jumper wires
• 10k ohm resistor
• USB cable
• Telephone cable wire
• Electrical wire
• Electrical tape
• Brush on electrical tape
• Cell phone charger
Parts and tools:
• Project box
• Philips screwdriver
• Hot glue gun
• Heat shrink
• Soldering Iron
• Heat gun
• Wire cutter & strippers
Step 2: Breadboard the Circuit
As always, it's best to test the circuit before you make it permanent.
I attached the schematic to this step so you can see how to make this circuit.
Step 3: Circuit p.1
Step 4: Circuit p.2
Your circuit so far should have a female audio jack hooked up to two solder pads on the perf board, then an 8 DIP socket soldered down to the middle. Lets add the switch.
The kind of switch we will be using is an SPDT switch with an off position. Basically it directs current through one of two wires or neither of them. So the switch three positions.
1. OFF 2. ON (wire 1) 3. ON (wire 2)
| \ /
| | | | | |
| | | | | |
Step 5: Circuit p.3 (The last part!!!)
There should be three wires coming from the relay and motion sensor. On is +5v, the other is GND, and the third is control. It may be labeled (CT, C or Vout).
The Motion Sensor
Step 6: Program the ATtiny85
GND--------- pin 4
5v ------------ pin 8
Pin 13 ------ pin 7
Pin 12 ------ pin 6
Pin 11 ------ pin 5
Pin 10 ------ pin 1
Change the programmer to "Arduino as ISP" (Tools>Programmer>Arduino as ISP)
If you can't get the ATtiny85 to program get more info here.
Step 7: Making the Power Cable
It is time to make the power cable. For this step you will be needing a phone cable, USB cable, and an male audio cable. What we are trying to do is make a long cable to carry 5v to our project. I figured that the easiest way to do that was to use a cell phone charger.
Plug the male mono jack into the female audio jack and make sure the circuit is getting power.
Step 8: Trimming
The perf board won't fit in the project box so it will take a little cutting with the dremel to get it to fit. Take a sharpie and mark off a section. Happy cutting!
If your relay won't fit in the box you may want to trim it down too.
Step 9: Fitting the Fresnel Lens, Switch, and Audio Jack
Step 10: Protecting the Relay
Now I got some brush-on electrical tape and I brushed it over all the contacts on the back of the relay. This. would help eliminate any risk of shorting out the 120v AC wires.
Step 11: Readying the Wall
Step 12: Fitting the Project to the Wall
Now it's time to sew everything back up. First press the project box into the wall and then try to get the outlet cover to fit flat on the wall without any pressure. I would up just cutting the project box in half. I wasn't counting on all the wires they jammed in the wall box. Wrapping the circuit and relay in electrical tape might have been better. Anyhoo you do what works best for you.
Squeeze hot glue around the edges of the light switch cover and press it onto the wall. Make sure to wipe away any excess glue.
Step 13: Creating the Sticker
I didn't like the way the outlet cover looked because of my horrible cutting job, so I made a label. I'm just going to upload some of the pictures of the steps I took to make the sticker.
Step 14: Plug up & Enjoy!
Plug your cellphone charger into the wall. Then plug the USB end of the power cable into the phone charger and then plug the male audio jack into the female jack on the cover. Tape or tack the wire out of the way so that nobody will trip on it.
Now impress your friends by having them walk into your room before you do so that they can experience the awesomeness of your project!
Depending on the person you may want to change the time the light stays on on sensor mode. All you have to do is reprogram the ATtiny85. Where you see 300000 milliseconds in the code change it to whatever you want.
Step 15: Conclusion
This was my first attempt at making a good video for my instructable. I hope I did a good job. Any tips on making the video better?
Thank you for watching the video and viewing this instructable. If you like this i'ble please give it votes for the contests and don't forget to subscribe for more!