自定义 Arduino 库
为 Arduino® 创建自定义附加功能库
附加功能库是在 Arduino 硬件上执行的自定义 C++ 代码与在您的主机上执行的 MATLAB® 代码之间的通信接口。
使用附加功能库,最终用户可以在创建 arduino
连接对象时,通过包含库直接从 MATLAB 命令行访问 Arduino 的附加功能。有关附加功能库的示例,请参阅Control Motors Using Adafruit Motor Shield V2。
MATLAB Support Package for Arduino Hardware 为您提供了一个类框架,您可以使用这个框架来创建自定义附加功能库,以便与您的 Arduino 设备和连接的硬件扩展板一起使用。此支持包提供了帮助您开发插件库的类和函数,统称为 Arduino 附加功能软件开发工具包 (SDK)。
开始之前,请参阅Custom Add-On Library Concepts。
当您准备就绪,可以开始创建自己的插件库时,请按照 Create Custom Arduino Add-On Library 中的步骤操作,或观看创建自定义 Arduino 附加功能库。
类
matlabshared.addon.LibraryBase | Abstract class for deriving Arduino add-on libraries |
函数
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 |
主题
快速入门
- 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.
- 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 硬件资源和引脚图
- 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.
其他信息
- 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.