Skip to content

Commit 06799bb

Browse files
committed
I/O: Move GPIO examples away from I2C pins
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.
1 parent 3ddf2d7 commit 06799bb

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

java/libraries/io/examples/Interrupt/Interrupt.pde

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import processing.io.*;
22
color bgcolor = 0;
33

4-
// RPI.PIN3 refers to the physical pin 3 on the Raspberry Pi's
5-
// pin header, which is located on the third row, next to a
6-
// Ground pin
4+
// RPI.PIN7 refers to the physical pin 7 on the Raspberry Pi's
5+
// pin header, which is located on the fourth row, above one of
6+
// the Ground pins
77

88
void setup() {
9-
GPIO.pinMode(RPI.PIN3, GPIO.INPUT);
10-
GPIO.attachInterrupt(RPI.PIN3, this, "pinEvent", GPIO.RISING);
9+
GPIO.pinMode(RPI.PIN7, GPIO.INPUT);
10+
GPIO.attachInterrupt(RPI.PIN7, this, "pinEvent", GPIO.RISING);
1111
}
1212

1313
void draw() {
1414
background(bgcolor);
1515
}
1616

17-
// this function will be called whenever pin 3 is brought from LOW to HIGH
17+
// this function will be called whenever pin 7 is brought from LOW to HIGH
1818
void pinEvent(int pin) {
1919
println("Received interrupt");
2020
if (bgcolor == 0) {

java/libraries/io/examples/SimpleInput/SimpleInput.pde

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import processing.io.*;
22

3-
// RPI.PIN3 refers to the physical pin 3 on the Raspberry Pi's
4-
// pin header, which is located on the second row, next to the
5-
// 5v power pin
3+
// RPI.PIN7 refers to the physical pin 7 on the Raspberry Pi's
4+
// pin header, which is located on the fourth row, above one of
5+
// the Ground pins
66

77
void setup() {
8-
GPIO.pinMode(RPI.PIN3, GPIO.INPUT);
8+
GPIO.pinMode(RPI.PIN7, GPIO.INPUT);
99
// this is equivalent to addressing the pin with its GPIO number:
10-
// GPIO.pinMode(2, GPIO.INPUT);
10+
// GPIO.pinMode(4, GPIO.INPUT);
1111
}
1212

1313
void draw() {
1414
// sense the input pin
15-
if (GPIO.digitalRead(RPI.PIN3) == GPIO.HIGH) {
15+
if (GPIO.digitalRead(RPI.PIN7) == GPIO.HIGH) {
1616
fill(255);
1717
} else {
1818
fill(204);

java/libraries/io/examples/SimpleOutput/SimpleOutput.pde

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
import processing.io.*;
22
boolean ledOn = false;
33

4-
// RPI.PIN5 refers to the physical pin 5 on the Raspberry Pi's
5-
// pin header, which is located on the third row, next to a
6-
// Ground pin
4+
// RPI.PIN7 refers to the physical pin 7 on the Raspberry Pi's
5+
// pin header, which is located on the fourth row, above one of
6+
// the Ground pins
77

88
void setup() {
9-
GPIO.pinMode(RPI.PIN5, GPIO.OUTPUT);
9+
GPIO.pinMode(RPI.PIN7, GPIO.OUTPUT);
1010
// this is equivalent to addressing the pin with its GPIO number:
11-
// GPIO.pinMode(3, GPIO.OUTPUT);
11+
// GPIO.pinMode(4, GPIO.OUTPUT);
1212
frameRate(0.5);
1313
}
1414

1515
void draw() {
1616
// make the LED blink
1717
ledOn = !ledOn;
1818
if (ledOn) {
19-
GPIO.digitalWrite(RPI.PIN5, GPIO.LOW);
19+
GPIO.digitalWrite(RPI.PIN7, GPIO.LOW);
2020
fill(204);
2121
} else {
22-
GPIO.digitalWrite(RPI.PIN5, GPIO.HIGH);
22+
GPIO.digitalWrite(RPI.PIN7, GPIO.HIGH);
2323
fill(255);
2424
}
2525
stroke(255);

0 commit comments

Comments
 (0)