You should have a little bit of experience with Arduino to do this project. There is enough detail in this instructable to build it without but it would help to understand if you wanted to expand on it. Enough small talk, lets begin!
After uploading, open the serial terminal as well. The output can be read from there.
Remove these ads by
Signing UpStep 1Basic LED/Buzzer
1. Any Arduino or a deviation of it should work perfectly fine for this. $30 for the standard Uno. As long as it can be programmed by the Arduino IDE you will be fine.
2. A PIR sensor. I am using the Parallax PIR sensor. You can get it for about $10. The one from Adafruit should work fine if you set it on H (retrigger) which I will explain later. The one from SparkFun has the signal pin that goes LOW (off) on detection so there will be some code changing. I do not know exactly how that one outputs signals.
3. A prototyping breadboard will make this much easier. Otherwise you will be soldering pins. This should be anywhere from $5 to $15 depending on what kind you get.
The Parallax PIR sensor I use requires a 10-60 second warm up time in order to calibrate itself. It is best to have no movement while it is calibrating. I give it 30 seconds, which I incorporate into the code.
Here is how I have my PIR set up. It is built on a shield that fits over the Arduino but the pins are the same.
My PIR module has the jumper on the back set on H - retrigger. The pin will stay HIGH the motion is continuous. The signal pin is hooked up to Arduino pin 4. The LED is hooked up to Arduino pin 5. The other two white pins do not matter in the picture, those are soldered to my shield from another project.
During the warmup period, the red LED blinks two times per second. After 30 seconds, the LED will stop blinking rapidly. Generally the PIR will not blink that rapidly in normal use so you will know when the warmup period ends. Check the images for the wiring. Arduino PDE file is attached.
To use a buzzer, simply wire that up in place of the LED and remove the resistor. You should use a transistor if the buzzer is not a piezo and is in a white boxy form that generates the buzz by vibrating against a plastic piece.
| « Previous Step | Download PDFView All Steps | Next Step » |











































http://arduino-info.wikispaces.com/Brick-Pushbuttons%26OtherSwitches#Motion
Regards, Terry King
terry@yourduino.com
With that said the sensor would be bad to use as an active lighting device. You would have to be constantly moving for it to always be on.
What i did in my code a while back was setup some settings that determined how long the lights would stay on even though the sensor may have went back to a LOW state.
You could also use it as a switch, located near a door, situated to only be triggered when someone walks through the door.
My Project includes:
-2 PIRs at two different locations in the room
-1 at the door, so any one of the PIR will always be on while i'm in the room.
when i sit at my computer, the PIR underneath the desk triggers some lights around my computer.
when i sit at my tv, the back lights around my tv turn on.
The one at the door serves as a turn off protection.
So with a couple of these paired along with a program that keeps track of when certain lights should be on makes for a very nice lighting in my work area.
Also, i have 12v leds that use PWM with mosfets.
Good work, though.
if(millis() - lastMillis >900000) // 900000ms is 15 minutes
{
digitalWrite(light, LOW);
}
There would also be another if statement where every new motion would reset the timer to the current millis. This code operates on the difference between the stored and current millis. It works in the method of checking how long it has been since the last motion. If it exceeds 15 minutes or whatever time you decide, you can have it shut the light off.