Pir 2
Rosana
Posts: 5
Could someone show me the electrical circuit I have to build to use this program?
Thanks!
=========================================================================
'
'·· File...... PIR_Advanced_Demo.bs2
'·· Purpose... Demonstrate PIR Sensor With Warm-Up Code
'·· Author.... Parallax, Inc.
'·· E-mail.... support@parallax.com
'·· Started... 12-14-2005
'
'·· {$STAMP BS2}
'·· {$PBASIC 2.5}
'
' =========================================================================
'
[noparse][[/noparse] Program Description ]
' This PIR demo allows you to see how to go about allowing a warm-up time
' for the sensor to settle, as well as displayed number of times tripped
' and possibly activating an alarm or relay, in this case the LED.· The LED
' should have a 220 ohm or 330 ohm resistor in series with it.
'
[noparse][[/noparse] I/O Definitions ]
PIR············ PIN···· 0·············· ' I/O Pin For PIR Sensor
LED············ PIN···· 1·············· ' I/O Pin For LED
'
[noparse][[/noparse] Variables ]
counter········ VAR···· Byte··········· ' Trip Counter
'
[noparse][[/noparse] Initialization ]
DEBUG CLS······························ ' Clear DEBUG Screen
FOR counter = 40 TO 0·················· ' Wait 40 Seconds For PIR Warm-Up
· DEBUG HOME, "WARMING UP:", DEC2 counter
· PAUSE 1000··························· ' Display Counter Every Second
NEXT
counter = 0···························· ' Clear Counter Variable
DEBUG HOME, "WAITING...·· "············ ' Display Waiting Message
'
[noparse][[/noparse] Program Code ]
Main:
· DO
··· IF PIR = 1 THEN···················· ' Motion Detected?
····· counter = counter + 1············ ' Update Trip Counter
····· HIGH LED························· ' Light LED
····· DEBUG HOME, "TRIPPED...", DEC3 counter
····· DO : LOOP UNTIL PIR = 0·········· ' Wait For PIR To Clear
····· DEBUG HOME, "CLEARED...", DEC3 counter
····· LOW LED·························· ' Turn Off LED
··· ENDIF
· LOOP
Thanks!
=========================================================================
'
'·· File...... PIR_Advanced_Demo.bs2
'·· Purpose... Demonstrate PIR Sensor With Warm-Up Code
'·· Author.... Parallax, Inc.
'·· E-mail.... support@parallax.com
'·· Started... 12-14-2005
'
'·· {$STAMP BS2}
'·· {$PBASIC 2.5}
'
' =========================================================================
'
[noparse][[/noparse] Program Description ]
' This PIR demo allows you to see how to go about allowing a warm-up time
' for the sensor to settle, as well as displayed number of times tripped
' and possibly activating an alarm or relay, in this case the LED.· The LED
' should have a 220 ohm or 330 ohm resistor in series with it.
'
[noparse][[/noparse] I/O Definitions ]
PIR············ PIN···· 0·············· ' I/O Pin For PIR Sensor
LED············ PIN···· 1·············· ' I/O Pin For LED
'
[noparse][[/noparse] Variables ]
counter········ VAR···· Byte··········· ' Trip Counter
'
[noparse][[/noparse] Initialization ]
DEBUG CLS······························ ' Clear DEBUG Screen
FOR counter = 40 TO 0·················· ' Wait 40 Seconds For PIR Warm-Up
· DEBUG HOME, "WARMING UP:", DEC2 counter
· PAUSE 1000··························· ' Display Counter Every Second
NEXT
counter = 0···························· ' Clear Counter Variable
DEBUG HOME, "WAITING...·· "············ ' Display Waiting Message
'
[noparse][[/noparse] Program Code ]
Main:
· DO
··· IF PIR = 1 THEN···················· ' Motion Detected?
····· counter = counter + 1············ ' Update Trip Counter
····· HIGH LED························· ' Light LED
····· DEBUG HOME, "TRIPPED...", DEC3 counter
····· DO : LOOP UNTIL PIR = 0·········· ' Wait For PIR To Clear
····· DEBUG HOME, "CLEARED...", DEC3 counter
····· LOW LED·························· ' Turn Off LED
··· ENDIF
· LOOP
Comments
For the circuit diagram, see the datasheet from the product page on the Parallax website.