Quote Originally Posted by mychangl View Post
......
'*****INITIALIZING MCP23016 All as Output**************************************
I2CWrite SDA,SCL,CtrlDir1,Address,[00] 'Set as Output
Pause 10 'Delay 10ms
I2CWrite SDA,SCL,CtrlDir2,Address,[00] 'Set as Output
Pause 10 'Delay 10ms


Start :
Set1=$FF 'To turn on all LEDs connected to Set1
Set2=$FF 'TO turn ON all LEDs connected TO Set2

I2CWrite SDA,SCL,CtrlRW1,Address,[Set1] 'Turn on the LEDs
Pause 10 'Wait 10ms

I2CWrite SDA,SCL,CtrlRW2,Address,[Set2] 'Turn on the LEDs
Pause 10 'Wait 10ms

GoTo Start
You could have a label after the line where to jump if an error occurs with I2C, like this:
I2CWrite SDA,SCL,CtrlRW1,Address,[Set1], errorLabel
...
errorLabel:
LCDOUT "Error....