Main Content

Support Additional Peripherals Using Custom Arduino Libraries

R2026b
Create a custom Arduino library to integrate custom peripherals like LCD screens and NeoPixel LED strips

A custom Arduino® library is a communication interface between custom C++ code executed on the Arduino hardware and MATLAB® code executed on your development computer.

With custom Arduino libraries, you can access additional features of an Arduino directly from the MATLAB command line by including the libraries when creating an arduino connection object. For an example of a custom Arduino library, see Control Motors Using Adafruit Motor Shield V2.

The MATLAB Support Package for Arduino Hardware provides you with a framework of classes that you can use to create custom Arduino libraries to use with your Arduino device and attached hardware shields. The support package provides classes and functions to help you develop a custom Arduino library, collectively referred to as the custom Arduino library framework.

You can create a custom library using one of the following workflows:

Before you start, see Custom Arduino Library Concepts.

Classes

matlabshared.addon.LibraryBaseAbstract class for deriving custom Arduino libraries

Functions

expand all

sendCommandSend message to Arduino device from MATLAB
listArduinoLibrariesDisplay a list of installed Arduino libraries
validatePinValidate that pin supports specific functionality
getMCUGet microcontroller of Arduino board
getPinAliasGet alias pin number
arduinoio.customLibrary.downloadLibraryInstall Arduino compatible libraries (Since R2026b)
arduinoio.customLibrary.createLibraryTemplate Create custom library template (Since R2026b)
getTerminalsFromPinsGet terminal numbers from pins
getPinsFromTerminalsGet pin numbers from terminal
getTerminalModeGet current terminal mode
isTerminalDigitalCheck if terminal can be used as a digital pin
isTerminalAnalogCheck if terminal can be used as an analog pin
getServoTerminalsGet terminals that have servo functionality
getI2CTerminalsGet terminals with I2C functionality
getSPITerminalsGet terminals that have SPI functionality
getPWMTerminalsGet terminals with PWM functionality
getInterruptTerminalsGet terminals with interrupt functionality
configurePinResourceSet resource owner and mode of pin
decrementResourceCountDecrement count of number of instances of resource
incrementResourceCountIncrement current resource count
getResourceCountNumber of instances of a resource
getFreeResourceSlotGet first free slot of resource
setSharedResourcePropertySet shared resource property
getSharedResourcePropertyGet shared resource property
getResourceOwnerGet terminal resource owner

Topics

Getting Started

Arduino Hardware Resources and Pin Diagram

Additional Information