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 | |
|---|---|
| Name | interrupts() |
| Examples |
import processing.io.*;
color bgcolor = 0;
void setup() {
GPIO.pinMode(4, GPIO.INPUT);
GPIO.pinMode(5, GPIO.INPUT);
GPIO.attachInterrupt(4, this, "pinEvent", GPIO.RISING);
GPIO.attachInterrupt(5, this, "pinEvent", GPIO.RISING);
}
void draw() {
background(bgcolor);
}
void pinEvent(int pin) {
noInterrupts();
println("Received interrupt on pin" + pin);
if (bgcolor == 0) {
bgcolor = color(255);
} else {
bgcolor = color(0);
}
// re-enable interrupts
interrupts();
}
|
| Description |
Allows interrupts to happen You can use noInterrupts() and interrupts() in tandem to make sure no interrupts are occuring while your sketch is doing a particular task. By default, interrupts are enabled. |
| Syntax | .interrupts() |
| Returns | void |
