Files
processing4/java/libraries/io/examples/SimpleInput/SimpleInput.pde
gohai c30aa85ab9 IO: Use GPIO numbers in examples
Even the Raspberry Pi Foundation used GPIO numbers over (congruous) physical pin numbers:
https://www.raspberrypi.org/learning/introduction-to-processing/worksheet-2/

Switch our examples as well, so that it they're more clear and hardware-agnostic.
2016-02-14 01:07:37 +01:00

20 lines
402 B
Plaintext

import processing.io.*;
// GPIO numbers refer to different phyiscal pins on various boards
// On the Raspberry Pi GPIO 4 is physical pin 7 on the header
void setup() {
GPIO.pinMode(4, GPIO.INPUT);
}
void draw() {
// sense the input pin
if (GPIO.digitalRead(4) == GPIO.HIGH) {
fill(255);
} else {
fill(204);
}
stroke(255);
ellipse(width/2, height/2, width*0.75, height*0.75);
}