Can't connect MATLAB 2016 to Arduino using arduino() function ??

조회 수: 1 (최근 30일)
Kazi
Kazi 2016년 5월 28일
댓글: Walter Roberson 2019년 3월 10일
Hi,
I am working on a servo motor that's gonna receive an angle value from matlab. Previously we were using arduino ide but there were problems in creating an arduino serial communication. Then we began using serial communication with arduino built-in function in matlab 2016.
But problem did not go away. Even a few minutes ago, the servo was doing the job. Then when we ran the program again, this popped up, again,
" Failed to open serial port COM5 to communicate with board Mega2560. Make sure there is no other MATLAB arduino object for this board. For troubleshooting, see Arduino Hardware Troubleshooting."
This has been really frasustrating ! Please guyz, anyone have any idea what went wrong here or how to solve it ??
Thanks in advance.
a=arduino();
s=servo(a,'D9');
angle=30/180;
writePosition(s,angle);

채택된 답변

Walter Roberson
Walter Roberson 2016년 5월 28일
You have an existing arduino object. The single easiest way to make certain it is gone is to restart MATLAB.
  댓글 수: 2
Kazi
Kazi 2016년 5월 30일
편집: Walter Roberson 2016년 5월 31일
Thanks Walter, that worked. All I had to do was write these two in the beginning of the code
clear a
clear s
That's it !
Swapnil Desai
Swapnil Desai 2018년 5월 14일
I still can't get a connection, Is there any other solution ?

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

추가 답변 (1개)

HAMZA ABBASI
HAMZA ABBASI 2018년 6월 24일
편집: HAMZA ABBASI 2018년 6월 24일
write clear all in the first line of code
  댓글 수: 3
Alex Barbu
Alex Barbu 2019년 3월 10일
it doesnt work even I cleared all before writing the code. it gets the same error:
>> a=arduino('COM41','Uno');
Failed to open serial port COM41 to communicate with board Uno. Make sure there is no other MATLAB arduino object for
this board. For troubleshooting, see Arduino Hardware Troubleshooting.

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

카테고리

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