Step 1: Gather Materials.
-PICAXE 08M or 08M2
-8 Pin IC socket (optional but helpful)
- Audiovox, or similar vibration sensor. (Car alarm, or "shock sensor" (it doesn't actually shock anything it is just a vibration detector.))
-Radioshack project box. (6x4x2 or 7x4x3) http://www.radioshack.com/family/index.jsp?categoryId=2032276
- AA batteries and holder
- pager vibrator/motor (shown above, potted in hot glue)
- 5-12V siren (the louder the better)
- 2 General purpose N-channel FET (a logic level FET, such as FQP30NO6L works best, but most will probably work.)
- various resistors and capacitors
Step 2: PROGRAM THE ROBOT! Err I Mean the PICAXE
Nowadays everything runs on ARDUINO. I love arduino, but keeping my "embedded" intelligence in a project is almost always necessary. The arduino can definitely provide that intelligence, but they generally cost around $20-30, unless you use a barebones or a clone-duino, so they are much too expensive to dedicate to many projects. I like to build projects and let them sit around, I don't want to have to pull the brains out every time I want to build something new. That is why I love Picaxe. Each 08M picaxe only costs $2-3 and they can be reprogrammed many times, so they are cheap enough that I can leave all my projects intact and just smart enough to be useful.
Enough about that, now let's program this thing.
I program my picaxe via USB cable into the handy little programmer that includes a FTDI chip. Don't worry too much about the FTDI or what it means. Basically, you need a starter kit like the one sold HERE.
The usb cable is a special cable, which includes the USB to serial interface, so keep these details in mind if you decide to shop elsewhere.
There are many places on the web where you can learn exactly how to program a picaxe so I have omitted the details. PICAXE.COM for instance has a wealth of knowledge including full fledged user manuals! So much geeky knowledge I can hardly stand it.
I created the program initially in the picaxe's cool flowchart like programming language (see image), using an included program called "LOGICATOR". I have included both the Logicator (PLF) file and the BASIC (BAS) file. Download the file of your choosing with the programmer of your choosing and then remove the picaxe from the programmer so it can be installed in the next step when we ASSEMBLE THE MINIONS! err I mean, assemble the hardware.
Step 3: Assemble the Electronics
Note that I used 2 battery packs, labeled as 5Va and 5Vb, this isn't entirely necessary but the current draw from my motor was resetting the picaxe when ever it activated so I used a separate battery pack for it. Also note that the 5Vb can be from 5-12V if you have a higher voltage alarm for instance. Just make sure the voltage that you are substituting ONLY goes to the motor/alarm and NOT to the picaxe, it will make him angry. You wouldn't like him when he's angry. I did another silly thing and put the "disc style" pager motor into a bottle cap and then filled the bottle cap with hot glue. I did this because the pager motor was metal and I didn't want any shorting going on in my project box and because I have too much time on my hands.
The "shock" (vibration) sensor I used is a standard Audiovox, AUTO-ALARM style shock sensor. I think it is designed to run off of 12 volts but it worked perfectly for my purposes even at 5 volts. It has adjustable sensitivity so it can detect small vibrations up to larger jolts. You should be able to obtain one online by searching or at a best buy or similar store that sells car radios and alarm systems etc.
I also installed a rather large capacitor from 5Va to ground, but it doesn't appear in the schematic (an electrolytic 1000uF @35V I think).
Keep in mind if you decide to stray from the schematic that the picaxe doesn't like certain pins floating, meaning not connected, so if you don't use a pin you should put a 10k resistor from the pin to ground.
PRO TIP: Don't use giant expensive FETs like I did, they aren't really necessary for a project like this, plus they generally require a higher gate voltage to "turn on" and may heat up under certain conditions.
NOOB TIP: I included a picture of schematic symbols for the various kinds of FETs, which may be helpful. And a picture of a standard FET pin out.
Step 4: Assemble the Extremeties
Step 5: Project Box Cut-outs.
The photocell that peaks through a hole in the top of the project box is held in place with hot glue. To make it look nice I put tape over the hole and then hot glued the sensor in place. When the hot glue was dry I removed the tape, which left a nice looking sensor hole which is flush with the project box surface.
Step 6: Test Your Might!
1. The switch S2 remains closed and a low signal is sent to the picaxe pin3 (P4) When this happens the picaxe will check whether it is day or night, via the light sensor, and make a grumbly low tone on its internal speaker and then act accordingly.
2. The small internal speaker beeps and a person, with fingers nimble and fast, opens switch S2 within 1.5 seconds. The picaxe will acknowledge that the switch has been opened with a short happy little chirp, and will ignore any further input from the shock sensor for 15 minutes. ((A word of explanation is necessary. I originally intended to have S2 be a NC momentary switch, so when the internal speaker beeped you could hit the momentary button and disable it for 15 minutes. In actual usage 15 minutes is not that long and I found myself hitting the button again and again, so I changed it to a slide switch to facilitate my couch-potato worthiness.))
You may notice I never actually show my "alarm", that is because I don't have a picture of it, and I cannot get one, and you can't make me! Really, it was just the two wires shown in the schematic that exit through a small hole and connect to a "loud speaker" like 12V 100dB siren. It was so much larger than the actual project box that it looked funny sitting on my couch all the time so I disconnected it and haven't found a suitable replacement yet. Maybe I can do that in the future.
I hope you enjoyed this small project, I also hope you modify it in some way and make it better, or just make it bigger and grander! Put lights on it! Run some super eccentric code on an Arduino that communicates via wifi to the picaxe through an xbee via the picaxe's serial lines. I don't know just try stuff, it's fun.
Oh, and if I made some simple mistakes such as grammER or spealling or an incorrect schematic symbol, please tell me about it endlessly in the comments. ;)