I solved it myself.I reinstalled Matlab 2020a and added in Legacy MATLAB and Simulink Support for Arduino.I did not use the MATLAB Support Package for Arduino Hardware.As a result, I am now able to light up the LED in response to commands.
Communication test failure when setting up MATLAB Support Package for Arduino Hardware
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to connect MATLAB to an Arduino uno and turn on the LED. The communication test during setup of the MATLAB Support Package for Arduino Hardware fails and I am stuck. I ignore it and complete the setup, but when I run the following command, an error occurs:
>> a = arduino('/dev/cu.usbmodem101','Uno')
Error using: arduino
Too many input arguments.
>> a = arduino('/dev/cu.usbmodem101')
java.lang.NullPointerException thrown while loading gnu.io.RXTXCommDriver
java.lang.NullPointerException thrown while loading gnu.io.RXTXCommDriver
java.lang.NullPointerException thrown while loading gnu.io.RXTXCommDriver
Can't open: Port: /dev/cu.usbmodem101 is not available. No ports are available.
Use INSTRFIND to determine if other instrument objects are connected to the requested device.
Error using: arduino (line 83)
Could not open port: /dev/cu.usbmodem101
Writing from ArduinoIDE is possible, and the LED in the sample sketch can be lit. The port name specified in ArduinoIDE and the port name written in the above command match. The operating environment is as follows.
MacOS Sequoia ver15.3
Arduino Uno R3
I would appreciate any advice on how to solve this problem.
Antworten (1)
MathWorks MATLAB Hardware Team
am 15 Mai 2025
Hi ,
- MATLAB Support Package for Arduino Hardware should be fully compatible with MATLAB R2020a, and it is the recommended solution over the legacy support package.
- Installing the legacy support package is generally not necessary and may lead to compatibility issues .
Based on your description, the error messages indicate that MATLAB is unable to access the serial port (/dev/cu.usbmodem101) used by your Arduino. Here are some steps you can follow to resolve this:
1. Verify the Serial Port
- Make sure your Arduino is connected and visible to your Mac.
- You can check available serial ports in MATLAB using serialportlist:
serialportlist
- Ensure that /dev/cu.usbmodem101 appears in the output. If not, try reconnecting your Arduino or using a different USB cable/port.
2. Test Serial Communication
- Before using the Arduino support package, test if MATLAB can open the port using serialport:
s = serialport('/dev/cu.usbmodem101', 9600)
- If this fails, another application (such as the Arduino IDE) may be using the port. Close any such applications and try again.
3. Reinstall the Official Support Package
- Uninstall any legacy Arduino support packages.
- Reinstall the official MATLAB Support Package for Arduino Hardware via: Home > Add-Ons > Get Hardware Support Packages
- Follow the guided setup to completion.
4. Retry the Connection
- Try connecting with:matlabCopy codea = arduino('/dev/cu.usbmodem101', 'Uno')
5. Further Assistance
- If you continue to face issues, please contact MathWorks Technical Support for personalized help.
Recommendation:
For best results and future compatibility, always use the official MATLAB Support Package for Arduino Hardware rather than the legacy support package.
Best regards,
MATLAB Hardware Team
MathWorks
0 Kommentare
Siehe auch
Kategorien
Mehr zu MATLAB Support Package for Arduino Hardware finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!