close all; clc;

try
    fclose(s);
catch
    warning('s ne peut pas être fermé');
end
s = serial('COM7');
set(s,'BaudRate',9600,'Parity','none')
set(s,'DataBits',8)
set(s,'StopBits',1)
fopen(s);
pause(2);

% minuterie pour actualisation de l'affichage
deltaT = 10;
TotalTime_sec = 10*60; % 10 min
coups = round(TotalTime_sec/deltaT);
TSTART = tic;
eTime = 0;
for k = 1:coups
    while(eTime<k*deltaT)
        eTime = toc(TSTART);
    end
    U1 = check_u(127);
    U2 = check_u(127);
    w = strcat('0',num2str(U1,'%03d'),num2str(U2,'%03d'));
    fwrite(s,w,'uint8');

end


fclose(s);
