select case counter
case 2
led1 = 1
case 4
led1 = 1
case 6
led1 = 1
case 8
led1 = 1
case 10
led1 = 1
case else
led1 = 0
end select
or
if (counter = 2 )| (counter = 4) |,,,,, etc then
led1 = 1
else
led1 = 0
endif
select case counter
case 2
led1 = 1
case 4
led1 = 1
case 6
led1 = 1
case 8
led1 = 1
case 10
led1 = 1
case else
led1 = 0
end select
or
if (counter = 2 )| (counter = 4) |,,,,, etc then
led1 = 1
else
led1 = 0
endif
if (counter = 2 )| (counter = 4) |,,,,, etc then
led1 = 1
else
led1 = 0
endif
That's the simplest way huh? I guess being tired didn't matter. Thanks for the help.
Tony
it depends on how high count goes up to and wether it starts at 0
eq if the count was between 1 and 10 then all that's required is to check bit0 if it set then count is odd therefore led1 is off
Perhaps something like;/Henrik.Code:If Counter < 11 THEN If Counter // 2 = 0 THEN LED1 = 1 ELSE LED0 = 0 ENDIF ELSE IF Counter // 2 = 0 THEN LED2 = 1 ELSE LED2 = 0 ENDIF ENDIF
Can you do something like?
Code:If Counter< 10 then LED1 = Counter.0 : LED2 = NOT LED1
Hi Tony. How about
counter var byte
clear 'all variables
let portb =0 'off everything
loophere:
if counter = (your maximum number) then let counter = 0
let counter = (counter + 1)
pause 100
let portb = counter
goto loophere
You will have a binary output on portb and can use the appropriate pins depending on the counter number.
Due to the complexity of the rest of the code, I have the main code setting the pause time. The three gosub commands I have written will be immediate, so as not to interfere with the timing cycle of the aforementioned pause.
I have multiple outputs being controlled by two inputs. The outputs must reflect what the inputs are doing in real time, however, two of the outputs must run this code and not affect the timing of the rest of the outputs. A third set of outputs will execute another routine, but that code has already been written and tested. This is the last piece I have to finish.
Using the method I mentioned above, it adds 240 words to my assembly. The way I came up for this program to work in my setup is to have the counter increment with each pass. Half of the count will be dedicated to LED1 and the other half to LED2. It will simply alternate flash the way the code is written.
As I said, the timing portion is set by the main code, so no delays are in these subroutines, and hence, not affect the real time reflection of the inputs.
Bookmarks