Interfacing Arduino with MATLAB – Blinking LED
In this project, we are going to learn,
- How to set up hardware support for Arduino in MATLAB software.
- 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.
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.
After installing the support package for MATLAB, we need to check whether it is installed properly or not.
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.
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.
JLCPCB – Prototype 10 PCBs for $2 + 2 days Lead Time
China’s Largest PCB Prototype Enterprise, 300,000+ Customers & 10,000+ Online Orders Per Day
Inside a huge PCB factory: https://www.youtube.com/watch?v=_XCznQFV-Mw
This Post / Project can also be found using search terms:
- interfacing arduino in matlab
- interfacing arduino with matlab blinking led
- matlab and arduino interfacing project
- matlab code for blinking led