How to plot a graph with x and y axis input live from two hardware (arduino and laser gauge- UART)

3 次查看(过去 30 天)
Hi,
I'm a newbie to matlab. I'm trying to plot a graph where realtime data is received from a laser gauge using serial input (FT232), and pressure reading from a sensor using arduino. I tried to interface both the hardware to arduino but it wasn't an option recommended by the tech for the laser gauge and wasn't working.Serial signal was verified to work with tera term. Now I built up a code to receive that in matlab. I would like some help on how to now integrate that code to plot where the x axis is the source from arduino.
%
close all;
%serial object
s = serialport('COM4','BaudRate',9600);
% open serial port
fopen(s);
%plotting data
i=1;
while (1)
data (i) = str2double(fscanf(s));
if i <= 150
plot(data);
else
plot(data(end-150:end));
ylim([0 5]);
pause(0.01);
i=i+1;
end
  3 个评论
Mohammed Ammad
Mohammed Ammad 2022-11-13
Is it possible to get the data for the x and y axis from the hardware to plot the graph for 7 seconds and then stay idle?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Support Package for Arduino Hardware 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by