The Serial library reads and writes data to and from external devices one byte at a time. It allows two computers to send and receive data. This library has the flexibility to communicate with custom microcontroller devices and to use them as the input or output to Processing programs. The serial port is a nine pin I/O port that exists on many PCs and can be emulated through USB.
Issues related to the Serial library on different platforms are documented on the Processing Wiki. The source code is available on the processing GitHub repository.
When sending data to the console, such as via print() or println(), note that the console is relatively slow. It does not support high-speed, real-time output (such as at 60 frames per second). For real-time monitoring of serial values, render those values to the Processing window during draw().
Class for sending and receiving data using the serial communication protocol
Returns the number of bytes available
Sets the number of bytes to buffer before calling serialEvent()
Sets a specific byte to buffer until before calling serialEvent()
Empty the buffer, removes all the data stored there
Returns last byte received or -1 if there is none available
Returns the last byte received as a char or -1 if there is none available
Gets a list of all available serial ports
Returns a number between 0 and 255 for the next byte that's waiting in the buffer
Reads a group of bytes from the buffer or null if there are none available
Reads from the port into a buffer of bytes up to and including a particular character
Returns the next byte in the buffer as a char
Returns all the data from the buffer as a String or null if there is nothing available
Combination of readBytesUntil() and readString()
Stops data communication on this port
Writes bytes, chars, ints, bytes, Strings to the serial port
Called when data is available