Tuesday, January 30, 2007
Revised code for PIR sensor
‘ {$STAMP BS2}
‘ {$PBASIC 2.5}
PIR PIN 3 ‘ this is the P# port that your PIR is wired to
counter VAR Byte ‘ Trip Counter
Main:
DO
IF PIR = 1 THEN ‘ Motion Detected?
counter = counter + 1 ‘ Update Trip Counter
HIGH 10 ‘ send power to flexinol
DEBUG HOME, “TRIPPED...”, DEC3 counter
DO : LOOP UNTIL PIR = 0 ‘ Wait For PIR To Clear
DEBUG HOME, “CLEARED...”, DEC3 counter
LOW 10 ‘ Turn Off flexinol
ENDIF
LOOP
‘ {$PBASIC 2.5}
PIR PIN 3 ‘ this is the P# port that your PIR is wired to
counter VAR Byte ‘ Trip Counter
Main:
DO
IF PIR = 1 THEN ‘ Motion Detected?
counter = counter + 1 ‘ Update Trip Counter
HIGH 10 ‘ send power to flexinol
DEBUG HOME, “TRIPPED...”, DEC3 counter
DO : LOOP UNTIL PIR = 0 ‘ Wait For PIR To Clear
DEBUG HOME, “CLEARED...”, DEC3 counter
LOW 10 ‘ Turn Off flexinol
ENDIF
LOOP