Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time



p5.serialport is a p5.js library that enables communication between your p5.js sketch and Arduino microcontroller (or another serial enabled device).

This repository is part of the p5-serial project, for more info please visit


You don't need to install any dependencies!

The only prerrequisite for using with this library is first running a server using the companion library p5.serialserver, following the instructions on the repository


After running the server, you can create a client using the p5.serialport library.

We recommend first trying the included examples on the docs/ folder of this repo, which are also available online via GitHub pages at

Remember that you will likely have to change the name of the serial port in the examples to the one your serial device is using.

After you are familiarized with our examples, we suggest you use them as templates or basis of your own projects!


// returns a single byte of data (first in the buffer)
// serial.readChar() returns a single char 'A', 'a'
// serial.readBytes() returns all of the data available as an array of bytes
// serial.readBytesUntil('\n') returns all of the data available until a '\n' (line break) is encountered
// serial.readString() retunrs all of the data available as a string
// serial.readStringUntil('\n') returns all of the data available as a tring until a (line break) is encountered
// serial.last() returns the last byte of data from the buffer
// serial.lastChar() returns the last byte of data from the buffer as a char
// serial.clear() clears the underlying serial buffer
// serial.available() returns the number of bytes available in the buffer


Info about contributing is available at the main repository of this organization: