Step 1: Parts
In this project I used an ATtiny25 microcontroller, a handy little chip. I picked this one for this project because it's small and has 2 timers, which will make the programming easy. In order to complete this project you'll need a programmer, there are lots of methods on the internet for programming AVR's (look up "AVR programming" on instructables or google). I personally use the USBtinyISP that Ladyada sells.
Except for the AVR you can proabaly scalvange most of this stuff from old electronics. I needed to make an order to Digi-Key anyway, so I just got this stuff there.
What you need:
- 4.194304 MHZ Crystal
- 0.1 uF Capacitor
- 18 pF Capacitors (2)
- IC socket (optional)**
- Something to mount the parts on, and any tools needed to mount the parts (like a soldering iron).
**You don't need the IC socket, but it will make it very difficult to reprogram the AVR afterwards if you don't use one.
Step 2: Prepare the circuit
The parts should be placed according to the schematic I have attached, it's a pretty simple design. The big block in the center is the AVR, and the number beside all of the wires coming out of it corresponds to a pin. To figure out which pin is which, look at the microcontroller. You should notice a little circular indent beside one of the corner pins, this marks pin one. You count the pins going around the chip in a counter-clockwise direction starting here. In the picture the part marked G1 is the battery, C3 is the 0.1 uF capacitor, C1 and C2 are the 18 pF capacitors, Q1 is the crystal, and SP1 is the speaker. All of the GND's connect together (to the negative terminal of the battery).
Step 3: Program
Once you have everything set up, and the programmer attached, it's time to program. I have found that the speaker can't be attached while programming, so you should unhook that for this step. It is also very important that the crystal be attached (along with the 2 18 pF capacitors), as it will become necessary after burning the fuses.
DO NOT perform the next step (burn-fuse) if you are not using the crystal, once you do the AVR will require a crystal to operate. If you burn the fuses and you don't have a crystal your out of luck until you can get one.
Now, we need to burn the AVR's fuses (see a tutorial on AVR's for more information, and the above warning). To do so, run this command from within the same directory you have the files: main.c and Makefile.
If you are programming this thing some other way, the fuse values are:
Next run the next two commands to compile the program and program the AVR:
If you want you can run this command to clean up the excesses files that were created by the make command:
And there you go! Hopefully there weren't any errors and your AVR is programmed and ready to go. By default the AVR will wait for 15 minutes before doing it's thing, then beep for 1 second every 10 minutes for an hour. The beep frequency will be 17 KHz (quite high pitched). Check out the main.c file for more information and to change these values. I made sure to add lots of comments.
Step 4: Finish up and enjoy!
When you finish with that, it's time to test out your new toy. Have fun!
Credit goes to Ladyada (Limor), who's site has been extremely helpful getting me started with AVR microcontrollers.
Step 5: Enhancements
One good modification would be to find a way to increase the speakers volume. You could, for instance, drive the speaker with 2 AVR pins. Alternating which pin is on and off to provide the maximum possible voltage amplitude range to the speaker. You could also have the speaker go off at random intervals to provide maximum annoyance while making it even harder to locate.
I'll leave the details up to you, get creative and have fun!