MATLAB Answers

0

How to use Arduino code written in Arduino IDE file in MATLAB? How does it work?

Asked by An Gie Lo on 20 May 2018
Latest activity Commented on by amin ya on 19 May 2019
Greetings. I came across with this project:
In the link, two files were provided: one for matlab, one for arduino. The programmers used the centroid extracted from the face detected and tracked in matlab, and sent the coordinates to arduino to control the servos.
My question is: 1. How does the fopen(arduino) work? How does matlab know which arduino code file to access?

  0 Comments

Sign in to comment.

1 Answer

Answer by Ameer Hamza
on 20 May 2018

MATLAB does not need to know which Arduino sketch file you are using. Here is the procedure of what you need to do.
  1. You will first program your Arduino board, with the given code, using Arduino IDE. Download the Arduino code, open the Arduino IDE and create a new file and paste the downloaded code in the new file. Upload the program to the Arduino board.
  2. Note the port number for Arduino board from the Arduino IDE. Go to Tools menu > Port and note the port number such as COMx.
  3. After uploading the code, keep the Arduino connected using USB cable and open MATLAB.
  4. In the MATLAB code change the line
arduino=serial('COM6','BaudRate',9600);
and change COM6 to COMx you noted from MATLAB.
Now when you run the MATLAB code, it will communicate with the Arduino.

  1 Comment

So in this workflow it is possible to program Arduino hybridly? Both coding in native IDE and MATLAB?

Sign in to comment.