mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
I/O: Add examples
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import processing.io.*;
|
||||
color bgcolor = 0;
|
||||
|
||||
// RPI.PIN3 refers to the physical pin 3 on the Raspberry Pi's
|
||||
// pin header, which is located on the third row, next to a
|
||||
// Ground pin
|
||||
|
||||
void setup() {
|
||||
GPIO.pinMode(RPI.PIN3, GPIO.INPUT);
|
||||
GPIO.attachInterrupt(RPI.PIN3, this, "pinEvent", GPIO.RISING);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(bgcolor);
|
||||
}
|
||||
|
||||
// this function will be called whenever pin 3 is brought from LOW to HIGH
|
||||
void pinEvent(int pin) {
|
||||
println("Received interrupt");
|
||||
if (bgcolor == 0) {
|
||||
bgcolor = color(255);
|
||||
} else {
|
||||
bgcolor = color(0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user