Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Unable to stop Arduino Bluetooth data pulling

1 visualización (últimos 30 días)
Vincent I
Vincent I el 24 de Abr. de 2014
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
Hi, I would like to pull information from the arduino through bluetooth and be able to stop the data when a figure is closed. However, once I close the figure the code continues to run, I'm even unable to Ctrl+C in the command and the only way to stop the program is to close matlab.
Any ideas? Thank you
clear
clc
%fclose(instrfind)
%Open Serial COM Port
s = Bluetooth('RNBT-AD09',1);
fopen(s);
fid = fopen( 'Arduino.txt', 'w' );
g = figure;
pause(.5)
while ishandle(g) %Loop when Plot is Active
dat = fscanf(s)
fprintf(fid, '%s\r\n', dat);
end
fclose(fid);
fclose(instrfind);

Respuestas (1)

Vincent I
Vincent I el 24 de Abr. de 2014
Solved the problem by having a pause in the loop
while ishandle(g) %Loop when Plot is Active
dat = fscanf(s)
fprintf(fid, '%s\r\n', dat);
pause(.1)
end

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by