PinMode()

From Microduino Wiki
Jump to: navigation, search
void pinMode (uint8_t pin, uint8_t mode)

Set the mode of the pin

Configure the pin as input or output mode.

  • Parameter:

pin number of the pin

mode: INPUT, OUTPUT, or INPUT_PULLUP.

  • Example:
int ledPin = 13;                 // LED connected to digital pin 13

void setup()
{
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
}

void loop()
{
  digitalWrite(ledPin, HIGH);   // sets the LED on
  delay(1000);                  // waits for a second
  digitalWrite(ledPin, LOW);    // sets the LED off
  delay(1000);                  // waits for a second
}
  • Note:

Analog pin can also be used as digital pin, and the numbers are 14 (corresponding to the analog pin 0) to 19 (corresponding to the analog pin 5).

[Return to Arduino Syntax Manual]