void pinMode(uint8_t pin, uint8_t mode);
The pinMode() function sets the basic I/O operating mode of a pin. The pin parameter specifies the numeric (or symbolic when used with preprocessor macros) identifier for the I/O pin on the board. mode sets the operating mode and can be one of INPUT, INPUT_PULLUP, INPUT_PULLDOWN, INPUT_PULLUPDOWN, OUTPUT or OPEN.
None
INPUT :This sets the pin to be a normal floating input. The state of the input can be read using digitalRead(). An input in this mode with no connection or an open circuit will read an undefined value.
INPUT_PULLUP :Like INPUT this sets the pin to be in an input mode. However the internal pullup resistor (when available; not all boards have pullup resistors available on all pins) will be enabled. A pin in this mode with no connection will, when read with digitalRead(), return a HIGH value.
INPUT_PULDOWN :Like INPUT this sets the pin to be in an input mode. However the internal pulldown resistor (when available; not all boards have pulldown resistors available on all pins) will be enabled. A pin in this mode with no connection will, when read with digitalRead(), return a LOW value.
INPUT_PULLUPDOWN :Like INPUT this sets the pin to be in an input mode. However both the internal pullup resistor (when available; not all boards have pullup resistors available on all pins) and pulldown resistor will be enabled. A pin in this mode with no connection will, when read with digitalRead(), return an undefined value and any voltage seen on this pin will be roughly Vdd/2. This is a special case mode and should not be used under normal circumstances.
OUTPUT :The pin is placed into a mode where it can generate either a HIGH voltage (near Vdd) or a LOW voltage (near Vss or ground). The state of the pin can be set using digitalWrite().
OPEN :This is a special output mode where the pin acts as an open drain pin. This can be in two states - either open circuit or connected to Vss. When the pin is set to a HIGH level using digitalWrite() the pin is placed in a high impedance "open circuit" state. When the pin is set to a LOW level it is connected to Vss (ground). This mode can be used to create "wired or" connections (often used for multiple interrupt sources connecting to one interrupt input pin) or used to drive signals of a higher voltage than the main chip runs at (through the use of an external pullup resistor). Communications protocols such as I2C use open drain to allow multiple devices to share the same bus.
The pinMode() function conforms to, and expands upon, the Arduino 1.6.x specification.
To set a pin to an output and set it HIGH:
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
Input with a pullup:
pinMode(2, INPUT_PULLUP);
int inval = digitalRead(2);
digitalRead(), digitalWrite(), getPinMode(), pulseIn(), shiftIn(), shiftOut()