Hi. I am doing burglar alarm and stuck with last bit, when I come home. My one of PIR's detects me and it must give me 10s for alarm deactivation, but the same time it checks the serial keyboard input and on timeout trigers sirens. Im using Picaxe 18X1. There's copy of my program bit where picaxe reading keyboard input:
symbol key_input = b0 'keyboard input
INTRUDER_CHECK:
key_pos = 0
scan:
KEY_INPUT = 0
kbin KEY_INPUT
pause 170
goto key_pos_check
key_pos_check:
key_pos = key_pos + 1
if key_pos = 1 then
goto test1
elseif key_pos = 2 then
goto test2
elseif key_pos = 3 then
goto test3
elseif key_pos = 4 then
goto test4
ELSE
goto INTRUDER_CHECK
endif
test1:
if KEY_INPUT = b1 then
goto scan
else
goto INTRUDER_CHECK
endif
test2:
if KEY_INPUT = b2 then
goto scan
else
goto INTRUDER_CHECK
endif
test3:
if KEY_INPUT = b3 then
goto scan
else
goto INTRUDER_CHECK
endif
test4:
if KEY_INPUT = b4 then
INTRUDER_STATUS = 0
goto DEACTIVATE_ALARM
else GOTO INTRUDER_CHECK
endif
So if it doesn't go to DEACTIVATE_ALARM within 10s timer, it must start another sub..
Please help me a bit where I should insert or start my (what)timer, keeping in mind that it shouldn't be affected if burglar starts messing with keypad or I myself need to disable siren after more than 10s. Thank you very much.
symbol key_input = b0 'keyboard input
INTRUDER_CHECK:
key_pos = 0
scan:
KEY_INPUT = 0
kbin KEY_INPUT
pause 170
goto key_pos_check
key_pos_check:
key_pos = key_pos + 1
if key_pos = 1 then
goto test1
elseif key_pos = 2 then
goto test2
elseif key_pos = 3 then
goto test3
elseif key_pos = 4 then
goto test4
ELSE
goto INTRUDER_CHECK
endif
test1:
if KEY_INPUT = b1 then
goto scan
else
goto INTRUDER_CHECK
endif
test2:
if KEY_INPUT = b2 then
goto scan
else
goto INTRUDER_CHECK
endif
test3:
if KEY_INPUT = b3 then
goto scan
else
goto INTRUDER_CHECK
endif
test4:
if KEY_INPUT = b4 then
INTRUDER_STATUS = 0
goto DEACTIVATE_ALARM
else GOTO INTRUDER_CHECK
endif
So if it doesn't go to DEACTIVATE_ALARM within 10s timer, it must start another sub..
Please help me a bit where I should insert or start my (what)timer, keeping in mind that it shouldn't be affected if burglar starts messing with keypad or I myself need to disable siren after more than 10s. Thank you very much.