シリアル通信でArd​uinoから複数のデ​ータをMATLABに​送るやり方を教えてく​ださい

13 views (last 30 days)
Takaaki Yamazaki
Takaaki Yamazaki on 17 Jun 2020
ArduinoからMATLABにシリアル通信で1つのデータを送信しそれを受けてプロットするプログラムは作成できたのですが複数のデータを扱う方法が分からないので教えてください。
以下に1つのデータ扱うプログラムを記載します。
clear all
clc
s = serial('COM7', 'BaudRate', 9600, 'Terminator', 'CR', 'StopBit', 1, 'Parity', 'None');
fopen(s);
t=1;
out = 0;
while(1)
if (t<=30)
fprintf(s,'1');
out(t) = str2double(fscanf(s))
else
fclose(s);
delete(s);
clear s
break;
end
t = t+1;
end
t=1:1:30;
figure
plot(t,out,'-.')
hold on

Answers (0)

Categories

Find more on MATLAB Support Package for Arduino Hardware in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!