Introduction: Arduino I/O-Matlab Basic Tutorial

Picture of Arduino I/O-Matlab Basic Tutorial

this is my very first instructables and I was referred by an old member. Follow her link here: (

Its a simple illustration on how we can connect Arduino to Matlab and actually control and get information on Arduino
using Matlab

I have seen few tutorials regarding how to control or get data from Arduino using Matlab. Matlab is a very powerful tool for student and engineers a like. That's why i want to create this tutorial as a start for those, like me want to explore the 2 powerful tools in engineering and techs.

It's a rough start for me since this is my first post in instructables.... feel free to comment so i can improve it thanks!

here's the vid for the demo:

Step 1: Step 1: Things You Need to Know

In this tutorial you need to know the following:
1. Matlab and creating M-file and GUI (there are tons of tutorials online)
2. Arduino and Arduino programming
3. Arduino Support with Matlab
        tutorials from Giampiero Campa

Step 2: Step 2: Things You Need (materials)

1. PC with Matlab installed and the ArduinoIO package from MathWorks
2. Arduino
3. USB cable for the Arduino
4. LED
5. Photodiode (Photoresistor as an alternative)
6. Resistors

Step 3: Step 3: the Dreaded Process

Picture of Step 3: the Dreaded Process

For the Arduino:
1. Connect the circuit.
2. Connect your Arduino to your PC.
3. From the ArduinoIO (
     upload the adiosrv.pde to your arduino. Now your arduino will be the server that will accepting commands
     comming from Matlab.
For the Matlab
3. Run your Matlab as an administrator.
4. From the command window in Matlab type "install_arduino" (make sure that the active directory is in your ArduinoIO folder)
For this tutorial my idea is to make a manual and automatic lighting of an LED
5. Create an M-File in Matlab (or download below my GUI program). Make sure you have the right COM port of your Arduino)
     (the yes.m.txt is the program source code, the yes.fig.txt is the GUI just remove the txt extension)
6. Run the program. Enjoy!


YazminB (author)2015-10-30

I am trying download the code but I don´t can. please you can help me?

محمدق (author)2015-06-03

Please can you show code of matlab GUI

fansblink (author)2015-06-02

Very good tutorial, but I've tried many times, always just an error message like this below, can you help me? please

Error in gui_mainfcn (line 95)
feval (varargin {:});

Error in yes (line 16)
gui_mainfcn (gui_State, varargin {:});

Error in @ (hObject, eventdata) yes ('pbOn_Callback', hObject, eventdata, guidata (hObject))

DevendraD (author)2015-05-11

How can I connect BCILAB 1.1 output from MATLAB 2013b to arduino and then using it cntrolling servomotor? The picture depicted is dynamic graphical output of MATLAB .I want to use it control the servo motor.

jaykhade2233 (author)2015-03-17

how can we use serial commands in matlab to transmit data from tx and rx pin of arduino?

rmagtibay (author)jaykhade22332015-03-18

1. try to get the com port of your arduino

2. access the communication by accessing >>a = serial('COM1') -->> this is an example

3. then to open the communication >>fopen(a)

to access data (receive data) from the arduino >>fscanf(a)

4. to send data (transmit data) to the arduino >> fprintf(a,'your value here')

rmagtibay (author)2014-11-15

Hi, sorry for may late reply. you can download the codes here. the codes are:



just change the filename and remove the .txt extenstion

jorge alejandrol (author)2014-11-13

Can you pass me the code please? my email is

ahluoxiao2010 (author)2014-08-12

Good!where is the code ?

rmagtibay (author)ahluoxiao20102014-08-13

the yes.m.txt and yes.fig.tx if the file. download it and change the filename to:



put it on documents\matlab folder

MxJo.Teran (author)rmagtibay2014-11-10

great! can you borrow me the program code please?

kreyzeeblak (author)2014-09-03

i cant download the files

rmagtibay (author)2014-05-26

try to change the txt file that you download here

Alan Souza (author)rmagtibay2014-05-28

Thanks bro!

in my project i've building a Matlab GUI plotting real time data from arduino. But when I try to read two or more analog ports at the same time theres a error messege about the COM port. Do you know how I fix it?

rmagtibay (author)Alan Souza2014-05-28

can you send the codes ill try to look at it. thanks!

Alan Souza (author)rmagtibay2014-06-02

Send me your email for I send you the codes. Thank you

Alan Souza (author)2014-05-25

Great Job!!

I'm making a project that i'm using the arduino and matlab.

Can you send me the m.file and figure?


Analogue-Chick (author)2012-08-27

Welcome to Instructables! :D

rmagtibay (author)Analogue-Chick2012-08-27

Thanks ma aiz

amandaghassaei (author)2012-08-27

cool, great idea!

About This Instructable




Bio: the simpler, the better!!
More by rmagtibay:Arduino Based Automated Lighting ControlArduino I/O-Matlab basic tutorial
Add instructable to: