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

waitForInterrupt()

Examples
import processing.io.*;

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

  // trigger a reset of an external device with GPIO 4
  GPIO.digitalWrite(4, GPIO.HIGH);
  // wait for the device signalling us that it's ready
  // by pulling up our pin 5
  boolean success = GPIO.waitForInterrupt(5, GPIO.RISING, 1000);
  if (!success) {
  	println("Device didn't wake up in time");
  	exit();
  }
  // do something else...
}

Description Waits for the value of an input pin to change

The mode parameter determines when the function will return: GPIO.FALLING occurs when the level changes from high to low, GPIO.RISING when the level changes from low to high, and GPIO.CHANGE when either occurs.

This function returns true if the change, false if the timeout occured.
Syntax
.waitForInterrupt(pin, mode, timeout)
Parameters
pin int: GPIO pin
mode int: what to wait for: GPIO.CHANGE, GPIO.FALLING or GPIO.RISING
timeout int: don't wait more than timeout milliseconds (-1 waits indefinitely)
Returnsboolean
Updated on November 15, 2016 04:29:35pm EST

Creative Commons License