![]() |
![]() |
![]() |
![]() |
This project was born from my need to get back at a co-worker. He had been playing pranks on me for quite a while so I wanted to get him back. I had seen the "Annoy-a-tron" at Think Geek, but (1) it was too expensive and (2) it wasn't small enough. Also, I though it would be a pretty easy thing to make. I was right!
|
The schematic is very simple. Basically the Pic is provided with Ground and power. GPIO0 triggers the piezo and a .01uF capacitor cuts down on noise. |
![]() |
The asm code and project can be downloaded here, but I wanted to mention a couple things. First of all, I started by programming an LFSR for the random number generator, but I then found a more novel way to create the random numbers. I wanted to be able to get a random number between 2 and 15 (the amount of minutes between each beep) but it dawned on me that the sequence does not have to be truly random. In other words, once started (ie the battery put in) it should be random, but it can have the same sequence everytime the unit is started as it would probably be turned on and left on. The way I accomplished the randomness was to take a number to start with, say "0', add 11 each time, mask out the upper 4 bits, and this would be my new random #. So if you started with 0 (which means 0 minutes when it first starts, hence beeping right away when you put the battery in it) and then add 11, mask out the upper 4 bits, you would then have 11 as your next number (obviously.) Then you would add 11 again, masking out the bits would leave you with 6:Decimal
Binary
|
|
movlw 0x0B
; We will add
11 each time addwf LFSR, f ; to the LFSR movlw b'00001111' ; Make it 4 bit andwf LFSR, w movwf count ; And just use that for count variable incf count, f ; Add a couple so they're not too incf count, f ; close together - ie. "0" minutes incf count, f |
So basically, we get a random #, wait that many minutes, and then sound the speaker with a quick beep. Simple as can be. Have fun annoying your loved ones!!! |