Configures the specified pin to behave either as an INPUT or an OUTPUT. See the Digital Pins page for details on the functionality of the pins.
As of Arduino 1.0.1, it is possible to enable the internal pull-up resistors with the mode INPUT_PULLUP. Additionally, the INPUT mode explicitly disables the internal pull-up, regardless of the pin's previous state.
Use the following function to set the behavior of a pin:
pinMode(pin, mode)
The function admits the following parameters:
pin: the Arduino pin number to set the mode of.mode: INPUT, OUTPUT, or INPUT_PULLUP. See the Digital Pins page for a more complete description of the functionality.The function returns nothing.
Set the Arduino digital pin 13 (built-in LED) as an OUTPUT and toggle it by alternating between HIGH and LOW at a one-second pace
void setup() {
pinMode(13, OUTPUT); // Sets the digital pin 13 as output
}
void loop() {
digitalWrite(13, HIGH); // Sets the digital pin 13 on
delay(1000); // Waits for a second
digitalWrite(13, LOW); // Sets the digital pin 13 off
delay(1000); // Waits for a second
}
The analog input pins can be used as digital pins, referred to as A0, A1, etc. See the Analog Input Pins page for details.