How to plot the real time data from arduino?

53 views (last 30 days)
I have an Arduino program loaded to the Arduino. I want to plot the real time data from arduino in the MATLAB too. My MATLAB program can get the data from the Arduino board and plot successfully. However, it seems the MATLAB will write something to the Arduino board to override the Arduino program. Is it true? If the answer is positive, may I have a help that how can I get the data from Arduino without affecting the Arduino program? (P.S. both Arduino program and MATLAB program will read the same pin such as A0). Many thanks!

Accepted Answer

Arun Kumar
Arun Kumar on 12 Jun 2019
Hi Tommy,
Your observation is correct.
When you do a=arduino, an arduino server is built and is deployed to the hardware.
If you already have code running on arduino, I would suggest using serial read to read the data from serial port for plotting. Refer this page for details about reading data from com port.
anil simsek
anil simsek on 6 May 2020
I have Arduino code, I want to draw it instantly in matlab. Can you help me

Sign in to comment.

More Answers (2)

Sylvain on 17 Jan 2020
With a bit of delay, the issue is in your Arduino code:
Serial.available will return the number of bytes you can read. So you are telling your arduino to scan arriving signals:

anil simsek
anil simsek on 24 Feb 2020
Hi. I have an arduino code like this. this code prints the number of passes of this object on the screen when an object passes in front of the sensor.I also have to create an instant graphical simulation in Matlab that instantly shows the total number of passes of the do i do this in matlab? can you help me?
  1 Comment
anil simsek
anil simsek on 24 Feb 2020
this is my arduino code;
int ledpin=12;
bool turn=0;
int sayac=0;
void setup() {
void loop() {
turn =0;
void kesme() {
while( digitalRead (2)==1){turn=1; }

Sign in to comment.


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!

Translated by