
Originally Posted by
danielhr77
I want to blink a LED without the pause command because I want to do other things and not stop the entire loop every time the LED blinks.
SNIP
Without the pause command the code could look something like this:
count_on var byte
count_off var byte
pause_led var byte
count_on = 0
count_off = 0
pause_led = 5000
main:
if count_on = 0 then
high portb.0
endif
if count_on != pause_led
count_on = count_on + 1
endif
if count_on = pause_led then
low portb.0
count_off = count_off + 1
if count_off = pause_led then
count_on = 0
count_off = 0
endif
endif
goto main:
Daniel
I can suggest (without interrupts) the following
Code:
counter: var word
Led: var PortB.0
counter =0
main: if counter < HalfSecondValue then
counter=counter+1 ' increment the counter
else
counter = 0
Led = !Led ' toggle every half second
endif
' do whatever you have to do here
....
....
goto main ' go back to the top
Here, HalfSecondValue is something you will have to determine either by counting the machine cycles or experimentally(easier)
Jerson
Bookmarks