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

12 次查看(过去 30 天)
Kazi
Kazi2016-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 个评论

请先登录,再进行评论。

更多回答(1 个)

HAMZA ABBASI
HAMZA ABBASI 2018-6-24
编辑:HAMZA ABBASI 2018-6-24
write clear all in the first line of code
  3 个评论

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by