I/O: Add examples

This commit is contained in:
gohai
2015-10-12 00:11:55 +02:00
parent 59e05393a5
commit bc02e4b7b6
11 changed files with 275 additions and 0 deletions
@@ -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);
}
}