'countdown'
'designed to alert if lack of movement is detected
'allows six units of time, each of 2 minutes
'lights an l.e.d. (out6) on detection of movement
'sounds a buzzer (out7) if no movement detected after 12 minutes
'designed for PICAXE-18 or PIC 16F627 (HEX VERSION)



start:

set1:	let b3 = 1		'sets variable to keep track of count
	let pins = %00111111	'lights 6 red leds
	gosub timer

set2:	let b3 = 2
	let pins = %00011111	'lights 5 red leds
	gosub timer 

set3:	let b3 = 3
	let pins = %00001111
	gosub timer

set4:	let b3 = 4
	let pins = %00000111
	gosub timer

set5:	let b3 = 5
	let pins = %00000011
	gosub timer

set6:	let b3 = 6
	let pins = %00000001
	gosub timer

set7:	let pins = %11111111	'lights all and sounds buzzer
	wait 10			'sounds alarm for 10 secs

goto start

timer:
	for b2 =1 to 250	'starts timing loop
	pause 40		'pause 40 millisecs
	if pin1=1 then vib	'checks vibration switch
	pause 40		'pause 40 millisecs
	if pin1=1 then vib	'checks vibration switch
	pause 40		'pause 40 millisecs
	if pin1=1 then vib	'checks vibration switch
	pause 40		'pause 40 millisecs
	if pin1=1 then vib	'checks vibration switch
	pause 40		'pause 40 millisecs
	if pin1=1 then vib	'checks vibration switch
	pause 40		'pause 40 millisecs
	if pin1=1 then vib	'checks vibration switch
	next b2		

	goto vibskip		'times for 6x40x250 = 60 secs

vib:
	let pins = %01000000	'turns on green led when vib detected
	pause 500		'waits for 0.5 secs.
	if b3 = 1 then set1
	if b3 = 2 then set1	'moves count back a step if vib detected
	if b3 = 3 then set2
	if b3 = 4 then set3
	if b3 = 5 then set4
	if b3 = 6 then set5

vibskip: return









