-
Simple Timer question
Hello everyone
I failed miserably to get my head round HSERIN/HSEROUT yesterday so I am trying a new approach. I really need some background timer running so that I can set a time out a bit like this:
Main:
if portb.0 = 1 then gosub dostuff 'a pin gets waggled
'if 3 minutes is up then do something here
goto main
gosub dostuff
'reset the timer back to 0
return
Basically under normal circumstances pins will be going high and low and each time they do I want to set the timer back to zero, it is only if there is inactivity that I want to flag it, but do it in the background while the main code is executing. I have been trying to find a simple timer example that applies to me but can't quite understand what I need.
Thanks
-
Simple Timer Answer
Code:
INCLUDE "Elapsed.bas"
Gosub ResetTime ' Reset Time to 0d-00:00:00.00
Gosub StartTimer ' Start the Elapsed Timer
Main:
if portb.0 = 1 then gosub dostuff 'a pin gets waggled
IF MinutesChanged THEN
MinutesChanged = 0
IF Minutes = 3 THEN
'if 3 minutes is up then do something here
Gosub ResetTime ' Reset Time to 0d-00:00:00.00
ENDIF
ENDIF
goto main
dostuff:
; waggle as desired
Gosub ResetTime ' Reset Time to 0d-00:00:00.00
return