Processing on Raspberry Pi


Running a Sketch Without the Editor

In the previous section you saw how to run Processing and use its editor to create and run a sketch.  However you might find it more useful to run a sketch directly on the Pi without using the editor.  This is great for small displays like the PiTFT where using the Processing editor isn't easy.  You can also use this to run a sketch from a command terminal outside the graphic environment (like when connected to the Pi using SSH).

First make sure the graphical desktop environment is running.  Even though you aren't logging in and running commands in the desktop it still needs to run to show the Processing sketch.  Remember you can have the desktop automatically start on boot using the raspi-config command in the previous section (be sure to set the pi to boot and automatically log in).

Next copy your Processing sketch code to the Pi.  Remember a Processing sketch includes both a .pde file with the code and the directory that contains the .pde file.  For example a Processing sketch called HelloWorld would have a directory called HelloWorld and a file inside that directory called HelloWorld.pde.  Copy that directory and the files inside it to the Pi.

You can use a tool like FileZilla to connect to the Pi using SFTP and copy over files from your computer.  For example here's a picture of uploading a sketch called HelloWorld from my ProcessingSketchbook folder on my computer to the /home/pi folder on the Pi:

Take Away

This adafruit tutorial shows how I can automatically run a sketch on the Raspberry Pi platform. Given the general flexibility of raspberry pi, its small size, and its price point, it seems like the best hardware to create my own system.