My first post in this community! I'm very excited :)
So in this tutorial we're going to make a basic Motion Sensor alarm. What we're going to need is
- 1x Arduino (i'm using the Duemilanove, got mine from Sparkfun.com for about 60 bucks (for the starter kit))
- 1x PIR (can be found at Radio Shack for about 10 bucks)
- 1x Piezo Siren (Radio Shack, fairly cheap (max 10 bucks))
- 1x Voltage Regulator (12V, model number 7812)
- 1x Resistor (I have no idea what it is, but the colors go brown, black, red, gold, and it works) -- *NOTE: I'm horrible with resistors, i never really understood them
- 1x PNP Transistor (max amperage 800mA)
- 1x switch
- 2x breadboards (just for neatness)
- at least one 9volt battery with clip
- Wires, lots of wires
First lets take a look at the basic diagram for the circuit, I'm no electrical engineer so I'm sure there are errors in my diagram, but I hope it conveys the general idea of what we're going to make.
As you can see i've had to make some edits to this image to add in the things i learned along the way.
Lets build the lower circuit first
Hook the 9volt clip up to the breadboard positive and negative strips, then take a while and run it from the positive strip to a row.
Here is where we're going to hook up to the Voltage Regulator, we're going this incase you want to add more 9volts and supply the siren with it's full 12volts of power (currently only giving it 9volts). If you were to use 2x 9volts in a series you'd get 18volts which is too much for the siren, the regulator would limit it back to 12volts.
Make sure the regulator is positioned so the collector pin and the wire from the power strip are on the same row
Connect the ground wire from the Base pin to the negative(ground) strip.
take another wire and run it from the emitter pin, to another open row, we're going to hook up the physical switch here. plug on wire from the switch into the same row as the pin from the emitter, and then the other wire into an open row.
Here is where we add the transistor (digital switch), it follows the same pin scheme as the regulator. Make sure you pay attention to which way the flat side is pointed!
now we're going to hook up the piezo siren itself! take the positive wire and hook it up to the row where the emitter pin on the transistor is plugged in, and the other wire goes to the negative(ground) strip.
Now we move to the other breadboard. I plugged the PIR directly into the breadboard because it was easier this way, no soldering required :) Make sure you remember which pins the output, positive, and negative are.
Sorry for the blurry picture :( We're going to plug in a wire from the 5volt pin on the Arduino to the row where the positive pin is plugged in at, and then another wire from the row where the negative pin is plugged in at to the ground on the Arduino.
Here we take a wire from where the Output pin is plugged in and run it to digital pin 12 (which will be the digital input pin in the program)
We're going to use Digital Pin 13 for our output. I did this because on the Duemilanove the onboard LED is also connected on pin 13. This let me test my program without having to listen to loud noises all the time.
Plug the wire from the output pin to the row where the base pin on the transistor is plugged in at. Basically what this will do is allow you to send a digital signal to the transistor (HIGH or LOW), which will then open or close the circuit
The final step is to take a resistor from the Emitter row and run it to an open row, then take a wire and run it from that row, to a ground pin on the Arduino (this closes the loop for the digital signal from the Arduino)
All finished! Now lets take a look at the program for it!
const int light = 13; //output and light
const int pirOut = 12; //read info from the PIR
int output = LOW;
int readState = LOW;
//set digital pin 12 as input
//set digital pin 13 as output
Serial.begin(9600); //for debugging
readState = digitalRead(pirOut);
delay(100); //delay a bit
Now go and test it! Also leave any feedback if you have any!
Technorati : Arduino, Motion Detector Alarm, PIR, Passive Infrared, Piezo Siren
Del.icio.us : Arduino, Motion Detector Alarm, PIR, Passive Infrared, Piezo Siren
Zooomr : Arduino, Motion Detector Alarm, PIR, Passive Infrared, Piezo Siren
Flickr : Arduino, Motion Detector Alarm, PIR, Passive Infrared, Piezo Siren