You can also test the bits in the priority that you want them and jump to the right routine to flip the relay on, then no fancy stuff (masking, tables, lookups, etc).
like (below is an idea, no idea if it will run) And it will look bad in PBC do to lack of IF ENDIF, but this should get you rolling. Assuming port A and B are PIR0 is RELAY0. Note I do not have the PBC manual with me and just received it and did not start using it do to conditionals, so below is just an idea. Take below and clean it up. Also, do not recall the two commands, the lookup and one other you can index and jump to them. Hope this helps.
Symbol PortA = 5 'assuming it is 5
Symbol PortB = 6 'check the ports in the PIC datasheet
'set PortA and B directions and make sure PortA is in digital mode (some pic need that)
top:
peek PortA, B0 'might have these backwards (I am at work no PBC here
if bit4 = 1 then turnon4 'highest priority camera
if bit2 = 1 then turnon2 'etc
goto top
turnon4:
poke PortB,%00010000
goto top
turnon2:
poke PortB,%00000100
goto top
Bookmarks