Changing bits to outputs

wabernat

New Member
Hey all. I've figured out how to read out bits from the input pins, save them to b0, and write them out to output pins using a Rube Goldbergish set of outputs:
Code:
if b0 = %00000000 then low B.3, B.2, B.1, B.0     pause 100 endif
if b0 = %00000001 then low B.3, B.2, B.1 high B.0 pause 100 endif
if b0 = %00000010 then low B.3, B.2, B.0 high B.1 pause 100 endif
etc.

Though this works, it does not pass for elegant code. Assuming I have four bits written in positions 3 to 0 on b0, what is the correct way to convert the bottom four bits of b0 to outputs without all this if-then kludging? I have read over the manuals, and don't see a clear instance of this. My hunch is that it involves masking, but I've not been able to get the syntax right.

Thanks as always,

--William
 

Technical

Technical Support
Staff member
outpinsB = b0 and %00001111

don't forget to make the pins outputs first e.g. using dirsB (or a high or low on each pin)
 
Top