Hello.
Can you please give us a bit more detailed description of what are you trying to achieve. In the meantime you could try this:
Code:
led_tm var word
led var byte
indx var byte
dbc var byte
led_f var bit
symbol key=porta.2
poke $1F,7 'turn off comparator
poke $9F,0 'turn off voltage reference
porta=0: portb=0
trisa=%00010100
trisb=%00000000
pause 500
led_f=0: led_tm=0: indx=3
MAIN:
pause 1
if key=0 then dbc=dbc+1 'use this if porta.2 is pulled high
'if key=1 then dbc=dbc+1 'use this if porta.2 is pulled low
if dbc=70 then gosub SWITCH_LED
if dbc>72 then dbc=72
if key=1 then dbc=0 'use this if porta.2 is pulled high
'if key=0 then dbc=0 'use this if porta.2 is pulled low
led_tm=led_tm+led_f
if led_tm=500 then
toggle led
led_tm=0
endif
goto MAIN
SWITCH_LED:
indx=indx+1
if indx>2 then indx=0
lookup indx,[1,2,3],led
toggle led
led_f=1
return
Bookmarks