Changing output binary number sequence? is it possible?
hi everyone, looking for a fix to my output problem, i am outputing a simple 1-8 on a counter loop on porte on a 18f4550.
Im usine porte 0-2, basically
Code:
cnt=0
loop:
porte = cnt
cnt=cnt+1
if cnt=8 then cnt=0
pause 10
goto loop
heres the problem, im driving an electroni circuit that is not a binary input but it does have a decimal output, it takes 3 inputs and outputs 0-7 but the 3 inputs are not binary, if i treat them as binary it works but the decimal output is out of order.
what i want to do is have a ?sequence? setting like getnextnumber(1,4,3,6,2,7,5,0) <fake code for example only>
in visual basic there is a lookup command, im not sure if there is something like this for pic basic pro.
I could do this with expanded code using lots of if then statements but i would like to keep my code pretty short.
any ideas would be helpfull.
Re: Changing output binary number sequence? is it possible?
Have you checked the manual?
If you do you'll find that there indeed is a LOOKUP command and that it does exactly what you want.
Code:
LOOKUP cnt, [1, 4, 3, 6, 2, 7, 5, 0], PORTE
/Henrik
Re: Changing output binary number sequence? is it possible?
thanks for the quick reply, yea i lost my manual, so i looked it up on the online manual, I think ive got it figured out.
Im going to pint out a new manual, hopefully this will stop a few of my questions. thanks again.