Here's a useful template for keeping your Prop-2 programs organized. The template includes code for debouncing the input to prevent false starts -- especially important when using a PIR sensor.
' =========================================================================
'
' File......
' Purpose...
' Author....
' E-mail....
' Started...
' Updated...
'
' {$STAMP BS2}
' {$PBASIC 2.5}
'
' =========================================================================
' -----[ Program Description ]---------------------------------------------
' -----[ Revision History ]------------------------------------------------
' -----[ I/O Definitions ]-------------------------------------------------
Sio PIN 15 ' SETUP = UP; no ULN
Trigger PIN 14 ' SETUP = DN
' -----[ Constants ]-------------------------------------------------------
IsOn CON 1 ' for active-high in/out
IsOff CON 0
#SELECT $STAMP
#CASE BS2, BS2E, BS2PE
T2400 CON 396
T38K4 CON 6
#CASE BS2SX, BS2P
T2400 CON 1021
T38K4 CON 45
#CASE BS2PX
T2400 CON 1646
T38K4 CON 84
#ENDSELECT
Open CON $8000
Baud CON Open + T38K4 ' B/R jumper installed
' -----[ Variables ]-------------------------------------------------------
timer VAR Word
' -----[ Initialization ]--------------------------------------------------
Reset:
OUTH = %00000000 : OUTL = %00000000 ' preset IOs
DIRH = %00000000 : DIRL = %00000000 ' set outputs (1s)
' -----[ Program Code ]----------------------------------------------------
Main:
timer = 0 ' reset timer
DO WHILE (timer < 100) ' wait for 0.1 sec input
PAUSE 5 ' loop pad
timer = (timer + 5) * Trigger ' update timer
LOOP
' prop code here
GOTO Reset
' -----[ Subroutines ]-----------------------------------------------------
' -------------------------------------------------------------------------
' -------------------------------------------------------------------------
' -------------------------------------------------------------------------
' -------------------------------------------------------------------------
' -----[ User Data ]-------------------------------------------------------