注意:这个解决方案(原名“Arduino IO包”)已不再支持。金宝app建议您使用Arduino支持包由MathWorks开发和支持:金宝app
——MATLAB支金宝app持包Arduino硬件:读、写和分析数据从Arduino传感器
//www.tatmou.com/hardware-金宝appsupport/arduino-matlab.html
- 金宝appArdu金宝appino硬件仿真软件支持计划:Arduino开发运行独立的算法
//www.tatmou.com/hardware-金宝appsupport/arduino-金宝appsimulink.html
使用这个遗留支持下面只有一个是正金宝app确的:
——你正在使用MATLAB R2013b或更早(但不是比R2011a早)。
——你需要模型块使您能金宝app够从你的Arduino交互流的输入和输出
——你需要的函数或块使您能够交互式地读或重置编码器
——你正在使用不受支持的Arduin金宝appo克隆不会工作与官方包(例如ChipKit32)
示例用法:
- - - - - - - - - - - - - - - - - -
%,连接板
一个= arduino (“COM9”)
%——指定销模式
a.pinMode(4、“输入”);
a.pinMode(13,“输出”);
%——数字i / o
a.digitalRead(4) %读销4
a.digitalWrite(13,0) %写0到13针
%——模拟i / o
a.analogRead(5) %阅读模拟销5
一个。analogWrite(155) %写155模拟销9
%——串行端口
一个。串行%串行端口
a.flush;%将电脑的输入缓冲区
a.roundTrip(42) %发送42 arduino和背部
%,伺服系统
a.servoAttach (9);%连接伺服销# 9
a.servoWrite (9100);%在销# 9到100度旋转伺服
val = a.servoRead (9);%从伺服在读取角销# 9
a.servoDetach (9);%从销分离伺服# 9
%——编码器
a.encoderAttach(0、3、2) %连接编码器# 0针3(销)和2(销B)
a.encoderRead(0) %阅读位置
a.encoderReset(0) %重置编码器0
a.encoderStatus;%获得所有三个编码器的地位
a.encoderDebounce(0, 12) %集防反跳推迟到12 (~ 1.2 ms)
a.encoderDetach (0);%分离编码器# 0
%——adafruit电动机盾(AFMotor库)
一个。motorRun(4,“前进”)%向前运行电机
一个。stepperStep(“前进”,“双”,100年);%移动步进电机
%——关闭会话
删除()
与此有关的一些幻灯片和示例包可以在这里找到:
//www.tatmou.com/matlabcentral/fileexchange/27843
最后,可以找到更详细的信息使用和故障排除在readme。txt文件包含在这个提交。
引用作为
詹坎(2022)。遗留MATLAB和Simulink对金宝appArdu金宝appino的支持(//www.tatmou.com/matlabcentral/fileexchange/32374-legacy-matlab-and-金宝appsimu金宝applink-support-for-arduino), MATLAB中央文件交换。检索。