' Sonic grenade control program for Deluxe prototype ' www.imakeprojects.com for full project details. ' March 2006 ' ' Sonic grenade control consists of a pull-pin (a switch which is CLOSED ' once pulled), an LED, and a SAFETY switch. Output is to a sonic alarm. ' ' Once pulled, the pin provides power to the PIC. LED immediately lights to ' show that system is ACTIVE. ' ' While SAFETY is depressed (ie low), the LED remains solid and program ' takes no action. ' ' When SAFETY is released (pin goes high via pullup) the LED begins flashing ' for a 5 second countdown. ' ' Once 5 seconds are up, LED goes OFF and ALARM is triggered for 5 seconds. ' ' After 5 seconds, all is silent for 1 minute (60 secs). ' ' After 60 seconds, the system "chirps" every 10 seconds until pin is ' re-inserted (thereby cutting power). A "chirp" is a brief flash of the LED ' and a brief ON of the alarm. ' ' ' Pin 1 = +V (via pull-switch) ' Pin 8 = GND ' ' Pin 4 (gp3, aka pin3 in picbasic) = Optional safety (input) - tie HIGH if unused ' Pin 2 (gp5, aka pin5 in picbasic) = Optional LED out (output) ' Pin 7 (gp0, aka pin8 in picbasic) = Alarm out ' symbol CMCON = $19 POKE CMCON, $07 ' Generic val for calibration POKE $3FF, $78 input 3 ' SAFETY in output 5 ' LED out output 8 ' ALARM out low 8 ' Init as alarm OFF high 5 ' Init LED on as confirmation we are up and running start: ' While SAFETY is LOW, do not start the countdown if pin3 = 0 then start gosub secflash ' 1 second of flashing gosub secflash ' 1 second of flashing gosub secflash ' 1 second of flashing gosub secflash ' 1 second of flashing gosub secflash ' 1 second of flashing low 5 ' LED off high 8 ' ALARM on pause 5000 ' ALARM on for 3 seconds low 8 ' ALARM off pause 60000 ' wait 60 seconds loop: high 5 ' LED on high 8 ' ALARM on pause 100 ' just a blink/chirp low 5 low 8 ' both back off pause 10000 ' 10 seconds... goto loop secflash: high 5 ' LED on pause 100 low 5 ' LED off pause 100 high 5 ' LED on pause 100 low 5 ' LED off pause 100 high 5 ' LED on pause 100 low 5 ' LED off pause 100 high 5 ' LED on pause 100 low 5 ' LED off pause 100 high 5 ' LED on pause 100 low 5 ' LED off pause 100 return