public class GPIO
extends Object
Modifier and Type | Field and Description |
---|---|
static int |
CHANGE
trigger when level changes
|
static int |
FALLING
trigger when level changes from high to low
|
static int |
HIGH |
static int |
INPUT |
static int |
INPUT_PULLDOWN |
static int |
INPUT_PULLUP |
static int |
LOW |
static int |
NONE |
static int |
OUTPUT |
static int |
RISING
trigger when level changes from low to high
|
Constructor and Description |
---|
GPIO() |
Modifier and Type | Method and Description |
---|---|
static void |
analogWrite(int pin,
int value) |
static void |
attachInterrupt(int pin,
PApplet parent,
String method,
int mode)
Calls a function when the value of an input pin changes
|
static int |
digitalRead(int pin)
Returns the value of an input pin
|
static void |
digitalWrite(int pin,
boolean value) |
static void |
digitalWrite(int pin,
int value)
Sets an output pin to be either high or low
|
static void |
interrupts()
Allows interrupts to happen
|
static void |
noInterrupts()
Prevents interrupts from happpening
|
static void |
pinMode(int pin,
int mode)
Configures a pin to act either as input or output
|
static void |
releaseInterrupt(int pin)
Stops listening for interrupts on an input pin
|
static void |
releasePin(int pin)
Gives ownership of a pin back to the operating system
|
static void |
waitFor(int pin,
int mode)
Waits for the value of an input pin to change
|
static void |
waitFor(int pin,
int mode,
int timeout)
Waits for the value of an input pin to change
This function will throw a RuntimeException in case of a timeout.
|
static boolean |
waitForInterrupt(int pin,
int mode,
int timeout) |
public static final int INPUT
public static final int OUTPUT
public static final int INPUT_PULLUP
public static final int INPUT_PULLDOWN
public static final int LOW
public static final int HIGH
public static final int NONE
public static final int CHANGE
public static final int FALLING
public static final int RISING
public static void analogWrite(int pin, int value)
public static void attachInterrupt(int pin, PApplet parent, String method, int mode)
pin
- GPIO pinparent
- typically use "this"method
- name of sketch method to callmode
- when to call: GPIO.CHANGE, GPIO.FALLING or GPIO.RISINGnoInterrupts
,
interrupts
,
releaseInterrupt
public static int digitalRead(int pin)
pin
- GPIO pinpinMode
,
digitalWrite
public static void digitalWrite(int pin, int value)
pin
- GPIO pinvalue
- GPIO.HIGH (1) or GPIO.LOW (0)pinMode
,
digitalRead
public static void digitalWrite(int pin, boolean value)
value
- true or falsepublic static void interrupts()
attachInterrupt
,
noInterrupts
,
releaseInterrupt
public static void noInterrupts()
attachInterrupt
,
interrupts
,
releaseInterrupt
public static void pinMode(int pin, int mode)
pin
- GPIO pinmode
- GPIO.INPUT, GPIO.INPUT_PULLUP, GPIO.INPUT_PULLDOWN, or GPIO.OUTPUTdigitalRead
,
digitalWrite
,
releasePin
public static void releaseInterrupt(int pin)
pin
- GPIO pinattachInterrupt
,
noInterrupts
,
interrupts
public static void releasePin(int pin)
pin
- GPIO pinpinMode
public static void waitFor(int pin, int mode)
pin
- GPIO pinmode
- what to wait for: GPIO.CHANGE, GPIO.FALLING or GPIO.RISINGpublic static void waitFor(int pin, int mode, int timeout)
timeout
- don't wait more than timeout millisecondspublic static boolean waitForInterrupt(int pin, int mode, int timeout)