How to measure time with Matlab while led diodes is on using Arduino? <p>I need measure time while led diodes is on for each one with Matlab guide. In Arduino code its sending data to Matlab if diodes are on:</p> <p>if(digitalRead(ledC1)==HIGH) { Serial.println("a"); } </p> <p>if(digitalRead(ledC2)==HIGH) { Serial.println("b"); } </p> <p>With my Matlab code, it works only if one diode is on, but it is not working if two diodes are on in the same time and not measure for each one. How measure for both diodes?</p> <p>Matlab code:</p> <p>function pushbutton1_Callback(hObject, eventdata, handles)</p> <p>s=serial('COM7','BaudRate',9600);</p> <p>fopen(s);</p> <p>try</p> <pre><code> while true pause(1); </code></pre> <p>A = fscanf(s,'%s');</p> <p>B = fscanf(s,'%s');</p> <p>if strcmp(A,'a')==0 % frist led dioda</p> <pre><code> tic; </code></pre> <p>end</p> <pre><code> seconds1=toc; </code></pre> <p>elapsedTime1 = fix(mod(seconds1, [0, 3600, 60]) ./ [3600, 60, 1]);</p> <p>set(handles.text8,'String',elapsedTime1);</p> <p>if strcmp(B,'b')==0 % second led dioda</p> <pre><code> tic; </code></pre> <p>end</p> <pre><code> seconds2=toc; </code></pre> <p>elapsedTime2 = fix(mod(seconds2, [0, 3600, 60]) ./ [3600, 60, 1]);</p> <p>set(handles.text9,'String',elapsedTime2);</p> <p>end</p> <p>end</p> <p>catch err</p> <p>fclose(s);</p> <pre><code>clear all return; </code></pre> <p>end</p>