Interfacing Arduino with MATLAB – Blinking LED




In this project, we are going to learn,

  1. How to set up hardware support for Arduino in MATLAB software.
  2. How to control an Arduino using MATLAB code.

We normally use Arduino IDE to write and upload codes to Arduino. The advantage of MATLAB is, it uses a high-level programming language which is easier than C / C++. The other advantage of using MATLAB is, we can see the results of I/O operations quickly (without compiling). Moreover, MATLAB provides plotting functions that we can use to quickly analyze and visualize data collected from Arduino. First, we are going to learn how to setup hardware support package for Arduino in MATLAB software. After setting up hardware support package for Arduino in MATLAB software, we are going to control LEDs that are connected to Arduino board using MATLAB code.




Interfacing Arduino with MATLAB - Blinking LED

Setup Hardware Support Package for MATLAB:

Step 1. Start MATLAB (latest Version preferred).

Step 2. In the Environment section, select Add-Ons > Get Hardware Support Packages.

Step 3. It will start the Add-On explorer window.

Step 4. Click on MATLAB Support Package for Arduino Hardware.

Step 5.  Click on Install, now the installer will ask you to log into your MathWorks account. If you don’t have MathWorks account, you can create an account during installation.

Step 6.  After logging in, Accept the license agreement and proceed to installation.

Step 7.  Now, wait for the package to download and install.

Step 8.  Now you have successfully installed Arduino Support Package for MATLAB.

Testing MATLAB:

After installing the support package for MATLAB, we need to check whether it is installed properly or not.

READ  7 Segment Display Interfacing with Arduino

1. Open MATLAB.

2. Connect Arduino to PC.

3. Type the following command in MATLAB command window.

a = arduino()

4. If we have more than one Arduino connected to PC, then we can specify the board type and COM  port to which it is connected using the following command.

Interfacing Arduino with MATLAB - Blinking LED schematics

a = arduino( ‘COM5’ , ‘uno’ )

5. After entering the above command, MATLAB will try to communicate with your Arduino, if successful, MATLAB will display the properties of Arduino board connected to PC.

Read more: Interfacing Arduino with MATLAB – Blinking LED




This Post / Project can also be found using search terms:

  • interfacing arduino in matlab
  • interfacing arduino with matlab blinking led

Leave a Comment

*
= 4 + 3

(Spamcheck Enabled)

Read previous post:
Better LEDs with just a trick of the light
Better LEDs with just a trick of the light

Light propagating in a layer of scattering nanoparticles, shows the principles of diffusion - like tea particles in hot water....

Close
Scroll to top