- Processing
- p5.js
- Processing.py
- Processing for Android

- Processing Foundation

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 | ### waitFor()
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
      GPIO.waitFor(5, GPIO.RISING, 1000);
      // if this takes longer than 1000ms an exception will be raised

      // GPIO.waitFor(5, GPIO.RISING);
      // would alternatively wait indefinitely

      // ...
    }
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. The optional timeout parameter determines how many milliseconds the function will wait at the most. If the value of the input pin hasn't changed at this point, an exception is raised for this line. Without a timeout parameter the function will wait indefinitely until the input pin has changed to the desired state.
Syntax |
    .waitFor(pin, mode)
    .waitFor(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
Returns | void

Updated on November 10, 2017 05:36:31pm EST