Arduino Issue: I cannot run any of my code. 'To create a new connection, clear the existing object.'

조회 수: 7 (최근 30일)
I have only just begun to learn how to work with arduinos in matlab. My code will not run past the third line, so here are the first few lines:
clearvars
clear all
ard_UltraS('COM4', 'Mega2560','Libraries','Ultrasonic') = arduino;
Matlab gives an error at the third line:
"MATLAB connection to Mega2560 at COM4 exists in your workspace. To create a new connection, clear the existing object."
I have tried clear all, clearvars, clearing that specific variable, restarting matlab, restarting my computer, and different USB ports. With each of these attempts i get the same error. Is there anything to clear the variable I haven't tried? or some way to make sure that the arduino is disconnected?
  댓글 수: 1
Rohan Kale
Rohan Kale 2020년 10월 16일
Hi William,
The construct of the syntax "ard_UltraS('COM4', 'Mega2560','Libraries','Ultrasonic') = arduino;" is not supported for creating an arduino object.
Please use the following syntax instead:
>> ard_UltraS = arduino('COM4', 'Mega2560','Libraries','Ultrasonic');
or
>> ard_UltraS = arduino;
Refer to the MATLAB documentation page on creating an arduino object.
Hope it helps.

댓글을 달려면 로그인하십시오.

답변 (1개)

Arun Kumar
Arun Kumar 2020년 10월 16일
Hi Willian,
Please refer the following page for correct syntax of the command.
Hope this helps!
-Arun

카테고리

Help CenterFile Exchange에서 MATLAB Support Package for Arduino Hardware에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by