Loading...


Since January 2010 there are 2 basic ways to interact with the Arduino board using MATLAB and Simulink:

MATLAB Interface for Arduino


You can download the code for free here : http://www.mathworks.com/academia/arduino-software/arduino-matlab.html

This lets you control your Arduino board over USB from a MATLAB session, in either Windows, Mac or Linux. For example you can instantiate an Arduino object from MATLAB using:

>> a=arduino('COM5');

and then do stuff like:

>> av=a.analogRead(5);

>> a.pinMode(13,'output');
>> a.digitalWrite(13,1);

>> delete(a)

or if you have a ladyada motor shield:

>> a.servoAttach(1);
>> a.servoWrite(1,45);

>> a.motorSpeed(4,200);
>> a.motorRun(4,'forward');

>> a.stepperSpeed(1,10);
>> a.stepperStep(1,'forward','double',100);

You can also download these slides: http://www.mathworks.com/matlabcentral/fileexchange/27843 or look at this video to learn more: http://www.mathworks.com/company/events/webinars/wbnr43537.html

Arduino Target for Simulink


This lets you use Simulink to create programs that run directly on the Arduino board. You can download the code for free here : http://www.mathworks.com/academia/arduino-software/arduino-simulink.html

The target (available for Windows only) allows a Simulink model (and possibly also Embedded Matlab Code) to be automatically converted to C/C++ code, compiled and downloaded to the Arduino. This is especially useful for control application that need to run at high sampling rate, and in cases where you don't want the Arduino to be connected to a host computer.