Processing is an open-source programming language and environment for creating visual arts, graphics, and interactive projects. It simplifies graphics programming, making it ideal for beginners and artists.

Features:

  • Designed for visual art and multimedia projects.
  • Built on Java, but simpler to use.
  • Examples: Drawing shapes, animations, and creating interactive visuals.

Examples

hello_mouse.pde

  • Draws a line from a fixed point to the current position of the mouse cursor
  • The draw() function is called repeatedly (about 60 times per second by default). It updates the canvas
// Hello mouse.
void setup() {
  size(400, 400);               // Creates a 400x400 pixel canvas.
  stroke(255);                  // Sets the line color to white (255 = max brightness).
  background(192, 64, 0);       // Fills the canvas with an orange-red background color.
}
 
// Draw a line between a fixed point (top-left) and the current mouse position
void draw() {
  line(150, 25, mouseX, mouseY);
}

Create a Graph with Processing

https://docs.arduino.cc/built-in-examples/communication/Graph/

Ground_A0.ino

find_com_port_manual.pde

Available ports:
0: COM5
1: COM6
2: COM7
3: COM8
4: COM15
Connected to: COM15
73
10223

find_com_port.pde

Available ports:
0: COM5
1: COM6
2: COM7
3: COM8
4: COM15
Could not open port: COM5
Checking for Arduino on port: COM6
Could not open port: COM7
Checking for Arduino on port: COM8
Checking for Arduino on port: COM15
Found Arduino port: COM15
Received data from Arduino: 102

processing_arduino_sonar.pde

modified processing_arduino_sonar.pde

Processing on Raspberry Pi

  • Sketch saved in /opt/processing-4.3

Installation

  • Update the System
sudo apt update && sudo apt upgrade -y
  • Visit the Processing download page and select the Linux ARM version, which is specifically designed for Raspberry Pi’s ARM processor.
  • Alternatively, you can directly download it via the terminal:
wget https://github.com/processing/processing4/releases/download/processing-4.2/processing-4.2-linux-arm64.tgz
  • Extract the downloaded .tgz file:
tar -xvzf processing-4.2-linux-arm64.tgz
  • Move the extracted folder to a standard location (e.g., /opt)
sudo mv processing-4.2 /opt/processing
  • To make Processing easily accessible, create a desktop shortcut:
nano ~/Desktop/Processing.desktop

Add the following content to the file:

[Desktop Entry]
Type=Application
Name=Processing
Exec=/opt/processing/processing
Icon=/opt/processing/lib/icons/pde-256.png
Terminal=false
Categories=Development;
  • Make the shortcut executable so you can double-click the desktop shortcut to run Processing
chmod +x ~/Desktop/Processing.desktop
  • If you want to run Processing directly from the terminal:
  1. Edit your .bashrc file:
    nano ~/.bashrc
  2. Add the following line at the end:
    export PATH=$PATH:/opt/processing
  3. Save and apply changes:
    source ~/.bashrc
  • Run processing_arduino_sonar.pde directly in the terminal
processing-java --sketch=/home/pi/sketchbook/processing_arduino_sonar --run

Notes:

  • ARM Compatibility: Make sure you’re using the ARM version of Processing, as the standard x86 version will not work on the Raspberry Pi’s ARM architecture.
  • Performance: Processing runs best on a Raspberry Pi 4 or later, especially for graphical-intensive sketches. For earlier Pi versions, consider optimizing your sketches for performance.

Run Sonar sketch from command line

  • Use processing-java command to run sketches in the command line using syntax:
processing-java --sketch=/full/path/to/your/sketch/folder --run
  • Create a Shell Script
nano start_processing_arduino_sonar.sh
#!/bin/bash
processing-java --sketch=/home/pi/sketchbook/processing_arduino_sonar --run
  • Make it executable
chmod +x start_processing_arduino_sonar.sh
  • Run the Script
./start_processing_arduino_sonar.sh

Create a desktop shortcut for the Sonar sketch

  • Create shortcut file
nano start_processing_arduino_sonar.desktop
[Desktop Entry]
Version=1.0
Name=Processing Sketch
Exec=/opt/processing/processing-java --sketch=/home/pi/sketchbook/processing_arduino_sonar --run
Icon=/opt/processing/lib/icons/app-256.png
Terminal=false
Type=Application
Categories=Application;
  • Make it executable
chmod +x processing_sketch.desktop
  • Double click to run sketch (Note: It may be harder to debug because this bypasses the Processing IDE and command line)