Sending data from Matlab to Arduino?

Hi all,

To start off, I'll let you know that I have extremely minimal experience with both Matlab and Arduino. This is the first project I've used either, and am still trying to grasp a basic understanding of how the data would be captured and transmitted by Matlab.

I am using a webcam to analyze the position of an object, and based on the data from Matlab, I want Arduino to control a motor's speed and direction. I found a great tutorial for the type of motor I'm using (a stepper bipolar motor) so all I need to be passed from Matlab to Arduino is one integer.

Is this going to be easy? A point in the direction of a tutorial on this subject would be a great starting point for me.


Use the search function at the top of this page and search for matlab. Lot of postings in the past.

MATLAB has published this in their community site:

-- The Quick Shield: breakout all 28 pins to quick-connect terminals

UPDATE: There are now 2 official and native ways to interact with the Arduino From MATLAB and Simulink. You can download the code for free form the mathworks web site (under Academia -> Hardware). I will give explicit links later.

MATLAB Interface for Arduino 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:


and then do stuff like:


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


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);

Arduino Target for Simulink This lets you use Simulink to create programs that run directly on the Arduino board.

In other words this package (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.


MATLAB Interface for Arduino:

You can also download these slides: or look at this video to learn more:

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 :

You can also look at the Arduino playground wiki: