A Processing library for sending and receiving multiple-value records on the serial port.
The SerialRecord library for Processing sends and receive records, containing multiple integers, over the serial port. It is intended for novice programmers: it is designed to be easy to use, to detect when it is used incorrectly, and to detect and report when it receives invalid data. It also has an option to display the data sent to the and received from the serial port on the canvas.
The library also provides a function,
SerialUtils.findArduinoPort()
, that attempts to find the
serial port that the Arduino is connected to. This can be used to write sketches
that do not need to be modified when they are run on another computer, or when
the Arduino is connected to another USB port. This function can be used
independently of the other functionality in this library.
Data is sent as comma-separated ASCII. This format is easy to view and interact with in the Arduino Serial Monitor, and is compatible with the Arduino Serial Plotter.
The Library can be used with the SerialRecord library for Arduino, but does not require it.
pot1:100,pot2:200
. This is the
format recognized by the Arduino Serial Plotter.Use Processing’s Contribution Manager to install this library:
Once the library has been installed, examples are available from the File > Examples menu.
Each example is designed to pair with an example in the SerialRecord library for Arduino library. However, the examples can also be used with other Arduino sketches (so long as those sketches are written to send or receive to expected number of values), or as a starting point for your own work.
The Examples wiki
page
describes the examples, and suggests which example from the SerialRecord
library for Arduino is intended for use with each Processing example. (For
example, the Processing SendSingleValue
sketch was designed to pair with the
Arduino ReceiveSingleValue
sketch.)
Some common problems and their solutions are described in the symptoms in Troubleshooting.
The canvas display of the most-recently transmitted and received lines is helpful during initial development, but at some point you may require a canvas that contains only what your code explicitly draws there.
The Code Recipes Wiki page contains recipes to disable the feature where SerialRecord displays information on the canvas, and to log serial communication to the console instead.
It is relatively easy to transmit data between the Arduino and Processing without a library.
The idea of providing this code as a library was inspired by code provided to students by the NYU Shanghai IMA “Interaction Lab” course, for them to copy and paste into their sketches.
Copyright (C) 2020-2022 Oliver Steele. This software is made available under the terms of the GNU LGPL License.