This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.

Class

GPIO

Name

pinMode()

Examples
import processing.io.*;

void setup() {
  GPIO.pinMode(4, GPIO.INPUT);

  // On the Raspberry Pi, GPIO 4 is pin 7 on the pin header,
  // located on the fourth row, above one of the ground pins
  // For this particular board one could also write:
  // GPIO.pinMode(RPI.PIN7, GPIO.INPUT);

  frameRate(0.5);
}

void draw() {
  // sense the input pin
  if (GPIO.digitalRead(4) == GPIO.HIGH) {
    fill(255);
  } else {
    fill(204);
  }
  stroke(255);
  ellipse(width/2, height/2, width*0.75, height*0.75);
}

Description Configures a pin to act either as input or output

Unlike on Arduino, where pins are implicitly set to inputs by default, it is necessary to call this function for any pin you want to access, including input pins.
Syntax
.pinMode(pin, mode)
Parameters
pin int: GPIO pin
mode int: GPIO.INPUT or GPIO.OUTPUT
Returnsvoid
Updated on March 16, 2016 10:39:13am EDT

Creative Commons License