pinMode()

pinMode() is the first arduino command needed to use a pin as a digital IO. It sets the pin to an input or an output and makes it ready for use. As mentioned before the DDRX or data direction register controls the direction that data passes through the port, this essentially sets the pin to an input or an output.

To set a pin to an output simply write the relevant register bit to 1. Setting the bit to 0 creates an input. To set pin 1 of port B to an input / output:

(Input)                    (Output)
DDRB |= (1<<DDB1);         DDRB &= ~(1<<DDB1);

Simple!