This project is a miniature 1-chip alarm. All you need is a tilt switch, battery and piezo to produce a complete alarm.
If you want a very high output, you can add a Darlington buffer transistor, piezo tweeter and a 10mH choke.
The chip does all the work.
It sits in sleep mode (100 microamps) and waits for the enable line to go high via the tilt switch.
It then produces a SPACE GUN alarm for approx 3 minutes and goes into sleep mode again.
The .asm and .hex forΒ 4 Alarm Sounds chip with Space Gun selected when A0 and A1
HIGH, is in the following files:
4 Alarm Sounds.asm
4 Alarm Sounds.hex
Below is the program written by the original designer of the project. It is complex and contains an instruction: movlw wabl_dir_mask ;change directionΒ This instruction is now allowed. Possibly it should be: movfw wabl_dir_mask ;change direction. I donβt know how he was able to compile the program. I could not assemble it.
Read through the program then look at the next program for PIC12F629. It is shorter, easier to read, has better sounds, includes sleep mode (100microamps) and a 3 minute timer. You can always learn from other peoples work.
Here are some of the things to consider.
1. The second program has has fewer instructions for each sub-routine. For instance:
decfΒ Β Β Β Β dwell,1 ; test if dwell = 0
btfscΒ Β Β Β ZERO
has been replaced with:
decfszΒ Β dwell,1 ; test if dwell = 0
gotoΒ Β Β Β Β Β $-2Β Β Β ;go up the program two instructions
2. The piezo lines toggle via the following instructions:
movlwΒ Β Β Β Β Β bβ00100001β²
xorwfΒ Β Β Β Β Β Β GPIO,1Β Β Β Β Β Β Β Β ;toggle bits 0 & 5
This makes GP0 and GP5 change state each time the sub-routine is executed. You do not need to know the previous state of either line. They change state each time the sub-routine is called.
3.Β Instruction:Β goto $+1Β Β uses 2 cycles and saves writing:Β Β Β nopΒ Β Β nopΒ and saves oneΒ line of code.
For more detail: 4 ALARM SOUNDS using PIC12F629