필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Unable to stop Arduino Bluetooth data pulling

조회 수: 1 (최근 30일)
Vincent I
Vincent I 2014년 4월 24일
마감: MATLAB Answer Bot 2021년 8월 20일
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);

답변 (1개)

Vincent I
Vincent I 2014년 4월 24일
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

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by