How to measure time with Matlab while led diodes is on using Arduino? -
i need measure time while led diodes on each 1 matlab guide. in arduino code sending data matlab if diodes on:
if(digitalread(ledc1)==high) { serial.println("a"); }
if(digitalread(ledc2)==high) { serial.println("b"); }
with matlab code, works if 1 diode on, not working if 2 diodes on in same time , not measure each one. how measure both diodes?
matlab code:
function pushbutton1_callback(hobject, eventdata, handles)
s=serial('com7','baudrate',9600);
fopen(s);
try
while true pause(1);
a = fscanf(s,'%s');
b = fscanf(s,'%s');
if strcmp(a,'a')==0 % frist led dioda
tic;
end
seconds1=toc;
elapsedtime1 = fix(mod(seconds1, [0, 3600, 60]) ./ [3600, 60, 1]);
set(handles.text8,'string',elapsedtime1);
if strcmp(b,'b')==0 % second led dioda
tic;
end
seconds2=toc;
elapsedtime2 = fix(mod(seconds2, [0, 3600, 60]) ./ [3600, 60, 1]);
set(handles.text9,'string',elapsedtime2);
end
end
catch err
fclose(s);
clear return;
end
Comments
Post a Comment