To detect the pin state you should use the input state, to pull down the line you should use output state.
So when you decide that one side should pulldown you use the trisx.x = 0. This will convert the input pin into an output pin, hence you set the pin to low with portx.x = 0. When you have finished you turn the pin into an input again with the tris instruction.
Cheers
Al.
Bookmarks