Cannot use arduino and matlab together due to serial port issues

125 visualizzazioni (ultimi 30 giorni)
Hi im doing a project utilising an ultrasonic sensor and attempting to send that data over to matlab in order to create an accupancy grid. To do this both matlab and the arduino IDE need to be connected to the same serial port. However, when i run the arduino first the code uploads fine, but when I attempt to run the matlab code it gives the error message that COM4 is not usable. The same thing happens when I restart my PC with and run the matlab code first, just with the arduino IDE giving the error message and not the matlab. What can I do to remedy the situation.

Risposte (1)

Priyank Pandey
Priyank Pandey il 16 Mag 2023
Hi Rafey,
If you are experiencing issues with the serial port being inaccessible when both Arduino IDE and MATLAB are running, it might be due to a conflict where both programs are trying to access the same port simultaneously. To resolve this issue, you can try the following steps:
  1. Close both the Arduino IDE and MATLAB.
  2. Disconnect the Arduino board from your computer.
  3. Open the Arduino IDE and go to "Tools" > "Port" and make sure that no serial port is selected.
  4. Close the Arduino IDE.
  5. Reconnect the Arduino board to your computer.
  6. Open MATLAB and try running your MATLAB code that communicates with the Arduino.
By ensuring that the Arduino IDE is not actively using the serial port before running your MATLAB code, you can avoid conflicts between the two programs. Additionally, make sure that you are using the correct serial port in your MATLAB code to establish communication with the Arduino board.
Regards
Priyank

Categorie

Scopri di più su MATLAB Support Package for Arduino Hardware in Help Center e File Exchange

Prodotti


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by