Main Content

Register Add-On Library

To register your custom MATLAB® Arduino® add-on library, add the working folder that contains the Arduino add-on library to the MATLAB path. For Create LCD Add-on example, add the +arduinoioaddons folder to the MATLAB path 'C:\Work'.

addpath ('C:\Work');

The files are now listed in the MATLAB Current Folder browser. Make sure that your Add-on library is available. Use listArduinoLibraries to check if the add-on library is available. The available add-on libraries in the Create LCD Add-on example are as follows.

ans = 


You can now write your MATLAB code by incorporating the new add-on library.

Create an arduino object, include the new add-on library, and set ForceBuildOn to true to reprogram the board. Arduino devices reuse cached code if the specified library matches a library name in the source code. Reprogramming forces the device to newly download the header file, ensuring current and accurate information. For Create LCD Add-on example, create an arduino object by including the add-on library.

a = arduino('com5','uno','libraries','ExampleLCD/LCDAddon','ForceBuildOn',true);
a = 

  arduino with properties:

                    Port: 'COM5'
                   Board: 'Uno'
           AvailablePins: {'D2-D13', 'A0-A5'}
    AvailableDigitalPins: {'D2-D13', 'A0-A5'}
        AvailablePWMPins: {'D3', 'D5-D6', 'D9-D11'}
     AvailableAnalogPins: {'A0-A5'}
      AvailableI2CBusIDs: [0]
             Libraries: {'ExampleLCD/LCDAddon'}

Create an add-on object by specifying the add-on library and other arguments based on your requirements.

For Create LCD Add-on example, create an LCD add-on object by specifying the add-on library and the pins configured on the Arduino device.

lcd = addon(a,'ExampleLCD/LCDAddon','RegisterSelectPin','D7','EnablePin','D6','DataPins',{'D5','D4','D3','D2'});

You can write the relevant commands based on your requirement and then run your MATLAB code.

See Also

| |

Related Topics