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

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

Réponses (0)

Catégories

En savoir plus sur MATLAB Support Package for Arduino Hardware dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!