Home Hardware Arduino Arduino a Processing

Arduino and Processing

Processing is an open source language/ development tool for writing programs in other computers. Useful when you want those other computers to „talk“ with an Arduino, for instance to display or save some data collected by the Arduino.

Simple Examples

Arduino comes with some basic examples for communicating with Processing (in Examples > Communication). These are useful for when you want to write both Arduino and Processing programs and have them talk to each other. This works best for communicating simple information. If you just want to control an Arduino board from a Processing program, you may want to use the Arduino library for Processing described below.

Arduino Library for Processing (and Firmata)

This library allows you to control an Arduino board from Processing without writing code for the Arduino. Instead, you upload a standard firmware (program) to the board and communicate with it using the library. The firmware is called Firmata, and is included in the Arduino software. The corresponding Processing library can be downloaded below.


Library for Processing v1.5: processing-arduino.zip (Updated 11 Nov. 2011)
(properties file here: processing-arduino.txt)

Library for Processing v2.0: processing2-arduino.zip (Updated 24 Aug. 2013)
(properties file here: processing2-arduino.txt)

Note: if you run Linux, you need to change Arduino.jar into arduino.jar, because Linux is case sensitive and it does not work if you don’t change this letter (Arduino.jar is in the folder „library“ of this Processing Library).

Processing library for arduinoMega: processing-arduinomega.zip (Updated 12 Apr. 2010)


  1. Unzip the library and copy the „arduino“ folder into the „libraries“ sub-folder of your Processing Sketchbook. (You can find the location of your Sketchbook by opening the Processing Preferences. If you haven’t made a „libraries“ sub-folder, create one.)
  2. Run Arduino, open the Examples > Firmata > StandardFirmata sketch, and upload it to the Arduino board.
  3. Configure Processing for serial: http://processing.org/reference/libraries/serial/
  4. In Processing, open one of the examples that comes with with the Arduino library.
  5. Edit the example code to select the serial port used by Arduino. Specifically, change the [0] in this line
        arduino = new Arduino(this, Arduino.list()[0], 57600);

    To find the correct item in the array, run this code in Processing:

        import processing.serial.*;
        import cc.arduino.*;

    The output window will enumerate your serial ports. Select the number corresponding to the serial port in your Arduino environment found under Tools > Serial Port.

  6. Run the example.


These functions are in the Processing Arduino Library and communicate (from Processing) with a Arduino, upon which the Firmata sketch has been installed.

Arduino.list(): returns a list of the available serial devices. If your Arduino board is connected to the computer when you call this function, its device will be in the list.

Arduino(parent, name, rate): create an Arduino object. Parent should be „this“ (without the quotes); name is the name of the serial device (i.e. one of the names returned by Arduino.list()); rate is the speed of the connection (115200 for the v2 version of the firmware, 57600 for v1). Note that in the v2 library, the rate parameter is optional.

pinMode(pin, mode): set a digital pin to input or output mode (Arduino.INPUT or Arduino.OUTPUT).

digitalRead(pin): returns the value of a digital pin, either Arduino.LOW or Arduino.HIGH (the pin must be set as an input).

digitalWrite(pin, value): writes Arduino.LOW or Arduino.HIGH to a digital pin.

analogRead(pin): returns the value of an analog input (from 0 to 1023).

analogWrite(pin, value): writes an analog value (PWM wave) to a digital pin that supports it (pins 3, 5, 6, 9, 10, and 11); value should be from 0 (always off) to 255 (always on).


import processing.serial.*;
import cc.arduino.*;

Arduino arduino;
int ledPin = 13;

void setup()
  arduino = new Arduino(this, Arduino.list()[0], 57600);
  arduino.pinMode(ledPin, Arduino.OUTPUT);

void draw()
  arduino.digitalWrite(ledPin, Arduino.HIGH);
  arduino.digitalWrite(ledPin, Arduino.LOW);

Library for Firmata v1

Download: processing-arduino-for-firmata-v1.zip

Note that Firmata v1 wasn’t divided into a library and firmware. Simply upload the Standard_Firmata firmware to your Arduino board.

Another example

External Resources

Podobné články

Leave a Reply