another option with more time to do other things:
Code:
counter var word
counting var bit
turn on 16 bit timer ' @4mHz osc, this will take .065535 seconds to roll over
counter = 0
MAIN:
IF TxIF = 1 THEN GOSUB TIMESTUFF ' TxIF is the timer interrupt flag
'USER CODE GOES HERE
GOTO MAIN
TIMESTUFF:
TxIF = 0 'clear interrupt flag
IF PIN_1 = 0 THEN
COUNTER = COUNTER + 1
COUNTING = 1
ENDIF
IF (COUNTING) AND (PIN_1) THEN
IF COUNTER <= 1830 THEN OUTPUT_1 = 1 ' 1 second = aproxx 15.25 counts
IF COUNTER >1830 AND COUNTER <18300 THEN OUTPUT_2 = 1
' if you want to do anything for time between 20 and 30 mins, here's a good spot for that
IF COUNTER >27450 THEN OUTPUT_3 = 1
COUNTER = 0
COUNTING = 0
ENDIF
RETURN
Nothing wrong with Aratti's example, just showing another way.
Bookmarks