Custom Arduino Libraries
An add-on library is a communication interface between custom C++ code executed on the Arduino hardware and MATLAB® code executed on your host-computer.
With add-on libraries, end-users 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 an add-on 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 add-on libraries to use with your Arduino device and attached hardware shields. This support package provides classes and functions to help you develop an add-on library, collectively referred to as the Arduino Add-On Software-Development-Kit (SDK).
Before you start, see Custom Add-On Library Concepts.
When you are ready to create your own add-on library, follow the steps in Create Custom Arduino Add-On Library or watch Create a Custom Arduino Add-On Library.
Classes
matlabshared.addon.LibraryBase | Abstract class for deriving Arduino add-on libraries |
Functions
sendCommand | Send message to Arduino device from MATLAB |
configurePinResource | Set resource owner and mode of pin |
decrementResourceCount | Decrement count of number of instances of resource |
incrementResourceCount | Increment current resource count |
getTerminalsFromPins | Get terminal numbers from pins |
listArduinoLibraries | Display a list of installed Arduino libraries |
getResourceCount | Number of instances of a resource |
getFreeResourceSlot | Get first free slot of resource |
setSharedResourceProperty | Set shared resource property |
getSharedResourceProperty | Get shared resource property |
getResourceOwner | Get terminal resource owner |
validatePin | Validate that pin supports specific functionality |
getPinsFromTerminals | Get pin numbers from terminal |
getTerminalMode | Get current terminal mode |
isTerminalDigital | Check if terminal can be used as a digital pin |
isTerminalAnalog | Check if terminal can be used as an analog pin |
getServoTerminals | Get terminals that have servo functionality |
getI2CTerminals | Get terminals with I2C functionality |
getSPITerminals | Get terminals that have SPI functionality |
getPWMTerminals | Get terminals with PWM functionality |
getMCU | Get microcontroller of Arduino board |
getPinAlias | Get alias pin number |
getInterruptTerminals | Get terminals with interrupt functionality (Since R2019a) |
Topics
Getting Started
- Custom Add-On Library Concepts
Learn about the workflow to create your own custom MATLAB Arduino add-on library. - Create Custom Arduino Add-On Library
Create your own custom MATLAB Arduino add-on library.
- STEP 1: Create Add-On Package Folder
- STEP 2: Create and Configure C++ Header File
- STEP 3: Create and Configure MATLAB Add-On Class
- STEP 4: Register Add-On Library
- Adapt Add-ons to New matlabshared.addon.LibraryBase Class
Learn how to configure your existing add-on class to the new matlabshared.addon.LibraryBase class.
Arduino Hardware Resources and Pin Diagram
- Add-On Resources
Learn how to manage Arduino hardware resources among your custom MATLAB Arduino add-on libraries. - Physical Terminals and Pin Numbers
Learn the difference between terminal numbers and pin numbers on your Arduino board.
Related Examples
- Create HelloWorld Add-On
Create your first MATLAB Arduino add-on library. - Create LCD Add-on
Create a custom MATLAB Arduino LCD add-on library.