IO lines

how to use IO lines of arduino as Bidirectional lines..?

A digital pin can switch between output-low and input. As if it is an open drain output.

Change the pin IO direction with pinMode. can be used anywhere

void loop(){
:
:
:
pinMode (pinX, OUTPUT);
digitalWrite (pinX, LOW);  // or HIGH
pinMode (pinX, INPUT): // or INPUT_PULLUP
:
:
:
bitXstatus = digitalRead (pinX);
:
:
}