Thank you Joe,
Unfortunately the PAUSE 1000 within my main loop is making the response too slow.
This is my main loop ( added your example) when I press on any of the 6 switches it needs to react faster than a second later. This is why I am thinking I probably need to use timer1.
Code:
Main:
l=0: y=0
WHILE !T0IF : WEND ; wait for timer to overflow
TMR0 = 193 ; load timer for 1ms
T0IF = 0 ; reset the overflow flag
IF (SW1=0) THEN Counters[0] = DelayTime : goto Channel1
IF (SW2=0) THEN Counters[1] = DelayTime : goto Channel2
IF (SW3=0) THEN Counters[2] = DelayTime : goto Channel3
IF (SW4=0) THEN Counters[3] = DelayTime : goto Channel4
IF (SW5=0) THEN Counters[4] = DelayTime : goto Channel5
IF (SW6=0) THEN Counters[5] = DelayTime : goto Channel6
FOR X = 0 to 5 ; cycle thru counters
IF Counters(X) > 0 THEN ; if counter is counting
Counters(X) = Counters(X) - 1 ; decrement counter
IF Counters(X) = 0 THEN ; if counter timed out
SELECT CASE X ; turn on the appropriate LED
CASE 0 : if led1 = 1 then gosub StartCharge1
CASE 1 : if led2 = 1 then gosub StartCharge2
CASE 2 : if led3 = 1 then gosub StartCharge3
CASE 3 : if led4 = 1 then gosub StartCharge4
CASE 4 : if led5 = 1 then gosub StartCharge5
CASE 5 : if led6 = 1 then gosub StartCharge6
END SELECT
ENDIF
ENDIF
NEXT X
;-------------------------------------------------/
; update counter /
;-------------------------------------------------/
counter = counter + 1
Pause 1000
If counter >= 60 then minutes = minutes + 1 : counter = 0
; trigger off if it is time
if minutes >= 720 then minutes = 0
GOTO Main
Bookmarks