Thanks to the new Hardware I/O libraries, Processing is now optimized for the Raspberry Pi. This makes it much easier to use the Raspberry Pi I/O pins, and send data back and forth with a Arduino.
Hardware I/O
The Hardware I/O library allows to access the computer’s hardware peripherals, such as digital inputs and outputs, serial busses, and the like, in a fashion similar to the Arduino platform. This library is only available for embedded Linux boards with the necessary kernel drivers, such as the Raspberry Pi. https://processing.org/reference/libraries/io/index.html
Become the Maker you were born to be. Try Arduino Academy for FREE!
Considerations and limitations can be found at https://github.com/processing/processing/wiki/Raspberry-Pi
New Processing / Raspberry Pi Tutorial – https://www.raspberrypi.org/learning/introduction-to-processing/
import processing.io.*;
boolean ledOn = false;
void setup() {
GPIO.pinMode(4, GPIO.OUTPUT);
// On the Raspberry Pi, GPIO 4 is pin 7 on the pin header,
// located on the fourth row, above one of the ground pins
// For this particular board one could also write:
// GPIO.pinMode(RPI.PIN7, GPIO.OUTPUT);
frameRate(0.5);
}
void draw() {
ledOn = !ledOn;
if (ledOn) {
GPIO.digitalWrite(4, GPIO.LOW);
fill(204);
} else {
GPIO.digitalWrite(4, GPIO.HIGH);
fill(255);
}
stroke(255);
ellipse(width/2, height/2, width*0.75, height*0.75);
}