Arduino stop to communicate with the computer during a "while" loop.
1 次查看(过去 30 天)
显示 更早的评论
Hi,
i have a trouble with arduino. I wrote a while loop that delete, for each cycle, the first number of a matrix. During the loop some time the connection with arduino is lost, and the program crash.
here an example of the matlab script
ar = arduino();
x = [0, 1, 1, 0, 1, 0, 0 ,1, 1];
counter = 0;
while ~isempty(x);
counter = counter +1;
if x(1) == 1;
writeDigitalPin(ar,'D13',1);
end;
if x(1) == 1;
writeDigitalPin(ar,'D13',0);
end;
x(1) = [];
end
I don't know why it happened.
Does it depend on the usb cable that connect arduino to the computer? I had to add a usb prolong form the arduino USB.
0 个评论
回答(1 个)
Ankita Nargundkar
2016-10-21
Attach the crash log and the exact error message you are seeing. That will help.
另请参阅
类别
在 Help Center 和 File 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!