add PIR motion check

main
yikth 5 years ago
parent 7388ed1922
commit f1b7b24602

@ -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

Loading…
Cancel
Save