Hi Dwayne,

Thanks for your help, sorry about the delay in responding I have just got back from London on business.

OK I can follow most of this but dont understand 2 things, why have u declared the variable TranslateData when it does not appear to be used ?

And the other one is
Counter=Counter+2 'Must skip every other byte for table!

On the lookup's this has got me confused.

I did not know you could say read porta as a byte, so i was expecting the code to use a lookup table (if one can hold 38 values) as the input and output data has nothing in common and may in some circumstances be duplicated

eg if input is 11011011 then output 00001100
if input is 00011111 then output 00001100
if input is 10101010 then output 01111111

so i suppose a nasty and not efficient way would be something like this - psuedo code

TRISA="11111111" 'set Porta to all input...8 bit
TRISB="00000000" 'set Portb to all output...8 bit.
ReadData var byte

MainLoop:
ReadData=Porta
If ReadData=11001111 then Gosub SUB1
If ReadData=11001111 then Gosub SUB2
If ReadData=11001111 then Gosub SUB3
Goto MainLoop

SUB1:
Portb=00110100 'outputs to portb
return

SUB2:
Portb=10111000 'outputs to portb
return


SUB3:
Portb=11111100 'outputs to portb
return


It is important to note that there is nothing common between the output and input data.

Thanyou


Moz