主要内容

使用自定义 Arduino 库支持其他外设

R2026b
创建一个自定义 Arduino 库以集成 LCD 屏幕和 NeoPixel LED 灯带等自定义外设

自定义 Arduino® 库是在 Arduino 硬件上执行的自定义 C++ 代码与在您的开发计算机上执行的 MATLAB® 代码之间的通信接口。

使用自定义 Arduino 库,您可以在创建 arduino 连接对象时,通过包含库直接从 MATLAB 命令行访问 Arduino 的附加功能。有关自定义 Arduino 库的示例,请参阅Control Motors Using Adafruit Motor Shield V2。

MATLAB Support Package for Arduino Hardware 为您提供了一个类框架,您可以使用这个框架来创建自定义 Arduino 库,以便与您的 Arduino 设备和连接的硬件扩展板一起使用。该支持包提供类和函数,帮助您开发自定义 Arduino 库,统称为自定义 Arduino 库框架。

您可以使用以下工作流之一创建一个自定义库:

开始之前,请参阅Custom Arduino Library Concepts。

类

matlabshared.addon.LibraryBaseAbstract class for deriving custom Arduino libraries

函数

全部展开

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 (自 R2026b 起)
arduinoio.customLibrary.createLibraryTemplate Create custom library template (自 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

主题

快速入门

Arduino 硬件资源和引脚图

其他信息