mirror of
https://github.com/processing/processing4.git
synced 2026-02-02 21:29:17 +01:00
It appears as if using the I2C pins for GPIO requires a restart of the Raspberry Pi before the I2C interface can be used again. Play safe and move the examples to pins that aren't used for anything else.
26 lines
574 B
Plaintext
26 lines
574 B
Plaintext
import processing.io.*;
|
|
color bgcolor = 0;
|
|
|
|
// RPI.PIN7 refers to the physical pin 7 on the Raspberry Pi's
|
|
// pin header, which is located on the fourth row, above one of
|
|
// the Ground pins
|
|
|
|
void setup() {
|
|
GPIO.pinMode(RPI.PIN7, GPIO.INPUT);
|
|
GPIO.attachInterrupt(RPI.PIN7, this, "pinEvent", GPIO.RISING);
|
|
}
|
|
|
|
void draw() {
|
|
background(bgcolor);
|
|
}
|
|
|
|
// this function will be called whenever pin 7 is brought from LOW to HIGH
|
|
void pinEvent(int pin) {
|
|
println("Received interrupt");
|
|
if (bgcolor == 0) {
|
|
bgcolor = color(255);
|
|
} else {
|
|
bgcolor = color(0);
|
|
}
|
|
}
|