This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.

Name

Serial

Examples
// Example by Tom Igoe

import processing.serial.*;

// The serial port:
Serial myPort;       

// List all the available serial ports:
printArray(Serial.list());

// Open the port you are using at the rate you want:
myPort = new Serial(this, Serial.list()[0], 9600);
  
// Send a capital A out the serial port:
myPort.write(65);

Description Class for sending and receiving data using the serial communication protocol.
Methods
available()
buffer()
bufferUntil()
clear()
last()
lastChar()
list()
read()
readBytes()
readBytesUntil()
readChar()
readString()
readStringUntil()
stop()
write()
Constructor
Serial(parent)
Serial(parent, baudRate)
Serial(parent, portName)
Serial(parent, portName, baudRate)
Serial(parent, portName, baudRate, parity, dataBits, stopBits)
Parameters
parent PApplet: typically use "this"
baudRate int: 9600 is the default
portName String: name of the port (COM1 is the default)
parity char: 'N' for none, 'E' for even, 'O' for odd, 'M' for mark, 'S' for space ('N' is the default)
dataBits int: 8 is the default
stopBits float: 1.0, 1.5, or 2.0 (1.0 is the default)
RelatedserialEvent()
Updated on January 21, 2019 10:05:14am EST

Creative Commons License