PiDuino Library

pinMode(pin, mode)

Configures the specified GPIO pin number as INPUT, OUTPUT or PWM pin.

Parameters

pin - The GPIO pin number.

mode - Can be the followings:
INPUT : Sets pin as input without pullup resistor.
INTPUT_PULLUP : Sets pin as input with pullup resistor.
INTPUT_PULLDOWN : Sets pin as input with pulldown resistor.
OUTPUT : Sets pin as output.
SOFTPWM_OUTPUT : Same effect as OUTPUT. (Not available yet, still In progress).
PWM_OUTPUT : Sets pin as hardware PWM output. (Only for a few pins and requires sudo, see Notes below)

Returns

None


Example

#include <Arduino.h>

int ledPin = 4; // GPIO4

void setup() {
	pinMode(ledPin, OUTPUT);
}

void loop() {
	digitalWrite(ledPin, HIGH);
	delay(1000);
	digitalWrite(ledPin, LOW);
	delay(1000);
}

Notes

Example

#include <Arduino.h>

int ledPin = 4; // GPIO4

void setup() {
        strcpy(GPIO_DRIVER_NAME, "/dev/mem");
        pinMode(ledPin, OUTPUT);
}

void loop() {
        digitalWrite(ledPin, HIGH);
        delay(1000);
        digitalWrite(ledPin, LOW);
        delay(1000);
}
GPIO PIN Available in RPi (40-pins) connector PWM channel
12 YES 0
13 YES 1
18 YES 0
19 YES 1
40 NO 0
41 NO 1
45 NO 1
52 NO 0
53 NO 1