The bear
Senior Member
Hi Everyone,
I'm trying to convert my projects into using symbols.
I can't work out how to use Pause, the program starts off OK, but the pauses don't run as calculated.
The program appears to use the preceding pause, instead of my 'w2'.
Any suggestions appreciated.
I'm trying to convert my projects into using symbols.
I can't work out how to use Pause, the program starts off OK, but the pauses don't run as calculated.
The program appears to use the preceding pause, instead of my 'w2'.
Any suggestions appreciated.
Code:
;PIR Rat Trap vers 1.6 (Symbols)(28.03.15)
;77 Bytes
#picaxe 08m2
#no_data
#com 8
Symbol PIRin = b1 ;PIR i/p
Symbol MTR = C.2 ;Motor
Symbol Pushbutton = pinc.1 ;Norm 0v
Symbol PIR = pinc.3 ;PIR state
Symbol paus = w2 ;pause
Let w2 = 1000 ;1000mS
let dirsC = %000101 ; pins c.0 c.2 outputs
low 0
init:
Label_09:
if Pushbutton = 0 then ;pinc.1 wired to +ve-
goto Label_09 ;via 1k0 & Reset switch (C.1)
else
high 0 ;Reset indicator, LED (C.0)
paus = w2/10 ;100mS
low 0
paus = w2*20*10 ; 20000mS ; wait 20 seconds-
endif ; for PIR to go LOW.
main:
paus = w2/10/20 ;100mS
Label_10:
readadc C.4, PIRin
if PIRin < 10 then gosub TRAP ;Dusk
goto Label_10 ;Daylight
TRAP: ;Checking Trap every 1 secs-
paus = w2 ;1000mS ; when dusk/dark
if PIR = 1 then gosub CAPTURE ;PIR active ;
return
CAPTURE:
paus = w2/10 ;100mS
high MTR ; switch Motor ON
paus = w2/50 ; 20 ;Motor runs 20mS
low MTR ; switch Motor OFF
paus = w2/2 ;500 ; wait 500mS
end
return ; return from sub
;Notes; Vers 1.5 in operation 02.02.15