Run Processing programs on your touchscreen RPi2

Run Processing 3 on the Touchscreen

Once I worked out all the bugs on the notebook (Figure 3), the sketch was copied over to the RPi2, from the Linux notebook, using the rcp command.

rob%  cd /home/rob/
rob%  rcp sketchbook/g4p_basic_slider/g4p_basic_slider.pde \
Figure 3: Processing edit window on the Linux laptop.

On the Pi, go to the Processing directory and start Processing. Then select File | Sketchbook and the g4p_basic_slider sketch. When the sketch appears in the edit window, hit Run to see how it works (Figure 4). If you flip the toggle, the screen background should change colors.

Figure 4: Processing app running on RPi2/PiTFT display.

All this can be done from the RPi2 TFT screen using the touchscreen desktop menus, command lines, and a wireless keyboard. Making the sketch a standalone application without having to start Processing is a topic for another article.

You'll notice that there are some limits to using the touchscreen display. First, screen real estate is limited, so graphical interfaces are likely to have only a few controls. Second, on the resistive touchscreen, fingers aren't very accurate for moving the mouse pointer. Use a smooth, blunt stylus for accurate mouse positioning. And, you'll still find a keyboard useful, at least, until you get all your desktop Processing apps built.

Next Steps

This brief introduction to Processing on a Linux notebook and the RPi2 simply changed the background color and sent text messages to the console as a toggle switch was flipped and a slider was slid. The next step is to tie those screen functions to physical actions on the GPIO pins. A simple example would be to toggle an external LED on and off. Or, perhaps you could adjust an LED's brightness according to the position of the slider.

As I mentioned earlier, standalone applications would also be nice and are something I'll tackle in another story. Try out the RPi2 with a small touchscreen display, your Linux notebook, and Processing. I think you'll find some convenient uses for the technology.

The Author

Rob "drtorq" Reilly is an independent consultant, writer, and speaker specializing in hardware hacking, the DIY/Maker movement, and the tech media and is a huge fan of Steampunk. Dr. Torq has posted hundreds of feature-length articles for top-tier tech media and print outlets. He's also presented tech talks at OSCON and other industry venues. Contact him at or +1-407-718-3274.

Buy this article as PDF

Express-Checkout as PDF

Pages: 4

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content