Arduino stop to communicate with the computer during a "while" loop.
Afficher commentaires plus anciens
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.
Réponses (1)
Ankita Nargundkar
le 21 Oct 2016
1 vote
Attach the crash log and the exact error message you are seeing. That will help.
Catégories
En savoir plus sur Arduino Hardware dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!