- Close both the Arduino IDE and MATLAB.
- Disconnect the Arduino board from your computer.
- Open the Arduino IDE and go to "Tools" > "Port" and make sure that no serial port is selected.
- Close the Arduino IDE.
- Reconnect the Arduino board to your computer.
- Open MATLAB and try running your MATLAB code that communicates with the Arduino.
Cannot use arduino and matlab together due to serial port issues
52 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Priyank Pandey
2023-5-16
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:
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Arduino Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!