tested pir motion buzzer

main
Yik Teng Hie 5 years ago
parent f1b7b24602
commit d232f8be74

@ -1,6 +1,7 @@
' {$STAMP BS2} ' {$STAMP BS2}
' {$PBASIC 2.5} ' {$PBASIC 2.5}
PirMotion PIN 9 PirMotion PIN 9
Spkr PIN 10 Spkr PIN 10
' DTMF output on pin 10 ' DTMF output on pin 10
@ -64,22 +65,24 @@ Dial_Number:
FOR repeatA = 0 TO 5 FOR repeatA = 0 TO 5
ResetCount: ResetCount:
countDown = 20 countDown = 0
Hold: Hold:
'DEBUG "Wait motion stop"
IF IN9 = 1 THEN Hold ' Motion detected, wait until no motion IF IN9 = 1 THEN Hold ' Motion detected, wait until no motion
DO DO
DEBUG "*" DEBUG "*"
countDown = countDown - 1 countDown = countDown + 1
DEBUG "State of IN9: ", #IN9 ' PIR sensor input 'DEBUG "State of IN9: ", #IN9 ' PIR sensor input
IF IN9 = 1 THEN ResetCount ' Motion detected, restart countdown IF IN9 = 1 THEN ResetCount ' Motion detected, restart countdown
PAUSE 1000 PAUSE 1000
LOOP UNTIL (countDown < 0) LOOP UNTIL (countDown > 20)
DEBUG "Timeout... Buzz..."
OUTPUT 10 OUTPUT 10
FOR cntA = 0 TO 10 FOR cntA = 0 TO 10
IF IN9 = 1 THEN ResetCount ' Motion detected, restart countdown
OUT10=1 OUT10=1
PAUSE 300 PAUSE 300
OUT10=0 OUT10=0

Loading…
Cancel
Save