%% Ecrit sur port serie
disp('-------------- START ----------------');


% % Create a serial port object for Interface box.
obj2 = instrfind('Type', 'serial', 'Port', 'COM7', 'Tag', '');
% % Create the serial port object if it does not exist
% % otherwise use the object that was found.
if isempty(obj2)
    obj2 = serial('COM7');
else
    fclose(obj2);
    obj2 = obj2(1);
end
% % Set the BaudRate
obj2.BaudRate = 9600;
% Set the TimeOut
obj2.Timeout= 50;
% % Connect to instrument object, obj2.
fopen(obj2);
disp('TSG port open');


for i=1:3000
    fprintf(obj2,'%s\n','t1= 14.0165, c1= 4.18931, s= 34.9436, t2= 13.6685');
    disp(num2str(i));
    pause(10);
end
fclose(obj2);
disp('Serial closed');
