diff --git a/Sample.bs2 b/Sample.bs2 index bbc9d0c..4e321e1 100644 --- a/Sample.bs2 +++ b/Sample.bs2 @@ -1,6 +1,7 @@ ' {$STAMP BS2} ' {$PBASIC 2.5} +PirMotion PIN 9 Spkr PIN 10 ' DTMF output on pin 10 #SELECT $STAMP @@ -29,6 +30,7 @@ hiLo VAR Bit ' Bit to select upper and lower nib cntA VAR Byte repeatA VAR Byte +countDown VAR Byte Parallax DATA $19,$16,$62,$48,$33,$3F ' Phone: 1-916-624-8333 ParallaxFax DATA $19,$16,$62,$48,$00,$3F ' Phone: 1-916-624-8003 @@ -58,8 +60,24 @@ Dial_Number: RETURN Buzzer: + INPUT 9 FOR repeatA = 0 TO 5 - PAUSE 20000 + + ResetCount: + countDown = 20 + Hold: + IF IN9 = 1 THEN Hold ' Motion detected, wait until no motion + + DO + DEBUG "*" + countDown = countDown - 1 + + DEBUG "State of IN9: ", #IN9 ' PIR sensor input + IF IN9 = 1 THEN ResetCount ' Motion detected, restart countdown + + PAUSE 1000 + LOOP UNTIL (countDown < 0) + OUTPUT 10 FOR cntA = 0 TO 10 OUT10=1