Arduino MATLAB Interface - How To Interface Arduino With MALTAB
Arduino MATLAB Interface - How To Interface Arduino With MALTAB
ELECTRONICS HUB
P R OJ E C T S | T U TO R I A L S | C O U R S E S | K I T S
HOME » GENERAL » ARDUINO MATLAB INTERFACE MADE EASY – HOW TO INTERFACE ARDUINO WITH MALTAB?
In this project, I’ll show you how the Arduino MATLAB Interface works and all the steps
involved in interfacing Arduino with MATLAB.
Arduino is one of the favorite prototyping platform among makers and hobbyists. MATLAB, on
the other hand, is a professional numerical computing tool used by engineers and scientists.
Interfacing Arduino with MATLAB makes things interesting as one is aimed at an entry and
hobbyist level of users while the other is a very complex tool used by professionals.
Table of Contents
1. How Arduino MATLAB Interface Works?
2. Installing MATLAB Support Package for Arduino
3. Interfacing Arduino with MATLAB and Testing the Support Package
4. Programming Arduino using MATLAB
5. CODE
6. Summary of Arduino MATLAB Interface
7. Applications of Arduino MATLAB Interface
https://www.electronicshub.org/arduino-matlab-interface/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+ElectronicsH… 1/12
12/29/2017 Arduino MATLAB Interface - How to Interface Arduino with MALTAB?
MATLAB addresses several such problems in Arduino Programming with the help of two types
of processes:
In order to achieve this, we need an extra package for MATLAB called MATLAB Support
Package for Arduino. This is o cially released by MATLAB and is available for free in their
website (you need to have an account to download this package).
After initializing the add-on, you will then get an options of how to install the package i.e. from
the internet or from a le already that is already downloaded. I’ve chosen to install from the
internet.
You will then get a list of all the available Support Packages. Select Arduino and check the
MATLAB Support Package. There are Arduino Support Packages for Simulink as well but we
will leave it for later.
https://www.electronicshub.org/arduino-matlab-interface/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+ElectronicsH… 2/12
12/29/2017 Arduino MATLAB Interface - How to Interface Arduino with MALTAB?
Now, the MATLAB Application will ask you to login to you MathWorks Account. If you have an
account, use those credentials and login or you can create an account during installation.
Next, accept the license terms and continue to download the package.
MATLAB will now download and install the selected packages. Sit back and relax until it is
done.
a = arduino ()
This step will create a connection between MATLAB and Arduino and returns with the
properties of the Arduino Board like COM Port, Name, etc. as shown in the screenshot below.
https://www.electronicshub.org/arduino-matlab-interface/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+ElectronicsH… 3/12
12/29/2017 Arduino MATLAB Interface - How to Interface Arduino with MALTAB?
If more than one Arduino board is connected to the computer and if you want to communicate
with a speci c board, use the following command.
NOTE: You have to clear the variable ‘a’ using the command ‘clear a’.
I’ll write a MATLAB Program in order to blink this LED for 10 times with a delay of 1 second.
Alternatively, you can connect an external LED with a current limiting resistor to the Digital Pin
13 and the following image shows the circuit diagram for this connection.
https://www.electronicshub.org/arduino-matlab-interface/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+ElectronicsH… 4/12
12/29/2017 Arduino MATLAB Interface - How to Interface Arduino with MALTAB?
In the le tab, go to New and select Script option. A blank editor will be opened. Paste the
code mentioned in the following section and save the le. It will be save as a .m le, which is
the extension for MATLAB Programs.
NOTE: Change the COM Port and Arduino Board according to your needs in the code.
After saving the le, click on Run option. The MATLAB program will interact with the Arduino
Board and will perform the desired option.
An important point to be noted is that the program will not be uploaded to Arduino and hence
if you reset or restart the Arduino Board, the program will be lost and you need to perform the
above steps once again.
There is another way to program Arduino Board through MATLAB, but we will see that later.
https://www.electronicshub.org/arduino-matlab-interface/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+ElectronicsH… 5/12
12/29/2017 Arduino MATLAB Interface - How to Interface Arduino with MALTAB?
CODE
4
5 % start the loop to blink led for 10 seconds
6
7 for i = 1:5
8
9 writeDigitalPin(a, 'D13', 1);
10
11 pause(1);
12
13 writeDigitalPin(a, 'D13', 0);
14
15 pause(1);
16
17 end
18
19 %end communication with arduino
20
21 clear a
https://www.electronicshub.org/arduino-matlab-interface/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+ElectronicsH… 6/12
12/29/2017 Arduino MATLAB Interface - How to Interface Arduino with MALTAB?
New
Leave a Reply
Your email address will not be published. Required elds are marked *
Comment
Name *
Email *
Website
https://www.electronicshub.org/arduino-matlab-interface/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+ElectronicsH… 7/12
12/29/2017 Arduino MATLAB Interface - How to Interface Arduino with MALTAB?
POST COMMENT
https://www.electronicshub.org/arduino-matlab-interface/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+ElectronicsH… 8/12
12/29/2017 Arduino MATLAB Interface - How to Interface Arduino with MALTAB?
ads by media.n
Teacher Education
Education Grants
Schools
Educational Leadership
Degrees
https://www.electronicshub.org/arduino-matlab-interface/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+ElectronicsH… 9/12
12/29/2017 Arduino MATLAB Interface - How to Interface Arduino with MALTAB?
ads by media.net
Universities
Student Education
Jobs In Education
MBA
Executive Education
Education Grants
Continuing Education
Bachelor Degrees
Teaching
PROJECTS BY CATEGORY
Electronics
Questions
https://www.electronicshub.org/arduino-matlab-interface/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+Electronics… 11/12
12/29/2017 Arduino MATLAB Interface - How to Interface Arduino with MALTAB?
https://www.electronicshub.org/arduino-matlab-interface/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+Electronics… 12/12