dim count as byte 'define variable count as byte
sub procedure Led_On
if Button(GPIO, 1, 10, 1) then 'detect HIGH on GP1
GPIO.B2 = 1
Delay_ms(10000)
else
end if
end sub
sub procedure Check_Vibration 'If GP1 is high reset counter
if Button(GPIO, 1, 10, 1) then
count = 0
else
end if
end sub
main:
ANSEL = 0
ADCON0 = 0
CMCON0 = 7
TRISIO = %00000011 'Set GP0 and GP1 as inputs , GP2 as output
GPIO.B0 = 0 'Initial GP0 value -> Input Dark Sensor
GPIO.B1 = 0 'Initial GP1 value -> Input Vibration Sensor
GPIO.B2 = 0 'Initial GP2 value -> Output LED
count = 0 'Initialize count
TestPin = 0 'Initialize value of Pin6
while True
do
if Button(GPIO, 0, 1, 1) then 'detect HIGH on GP0
Led_On
GPIO.B1 = 0
Check_Vibration
end if
count = count + 1
loop until count = 12
GPIO.B2 = 0
wend
end.