Warning: Unsuccessful read: A timeout occurred before the Terminator was reached. 'serial' unable to read any data

5 views (last 30 days)
Hello!
I am trying to read data from Arduino uno but get this error
"Warning: Unsuccessful read: A timeout occurred before the Terminator was reached. 'serial' unable to read any data".
Can anyone help me please?
Thank you in advance!
clear All
close All
COM = serial('COM2','BaudRate',9600);%5,'Terminator','CR');
set(COM,'TimeOut',10)
fopen(COM);
interv = 240;
init_time = 1;
x =0;
while (init_time < interv)
b = fscanf(COM) ;
b = b(2:end-2);
b = bin2dec(b);
x = [x,b];
plot(x);
grid on ;
init_time = init_time+1;
drawnow;
end
fclose(COM);
delete(COM);
clear COM;

Answers (0)

Categories

Find more on Instrument Control Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!