Plotting live data from Arduino in Matlab
8 ビュー (過去 30 日間)
古いコメントを表示
Hi all,
Apologies if this has already been covered - I couldn't find any information and I am new to Matlab and Arduino! I want to plot water level data obtained from my Arduino Uno plugged into a Milone eTape water depth sensor. I've got the code running successfully in a freeware software called SerialPlot but I want to plot this data into Matlab. The code I am using on the Arduino is below. How do I go about plotting the data in real time on Matlab?
Thanks so much in advance!
Dan
// the value of the 'other' resistor
#define SERIESRESISTOR 560
// What pin to connect the sensor to
#define SENSORPIN A0
void setup(void) {
Serial.begin(38400);
}
void loop(void) {
float Reading;
float level;
float Reading2;
float mapped;
Reading = analogRead(SENSORPIN);
// Serial.print("Analog reading ");
// Serial.println(Reading);
//convert the value to resistance
Reading2 = (1023 / Reading) - 1;
Reading2 = SERIESRESISTOR / Reading2;
//Serial.print("Sensor resistance ");
//Serial.println(Reading2);
mapped = map(Reading2, 658.89, 1695.43 , 150, 0);
// map (Reading2, Highest Depth Resistance, Lowest Depth Resistance, Depth Difference, Lowest Depth)
// Serial.print("");
Serial.println(mapped);
delay(10);
}
0 件のコメント
回答 (1 件)
Madhu Govindarajan
2016 年 2 月 3 日
have you tried animatedline function in MATLAB? I doubt you can do 100% real-time with Arduino but I think this is what you are looking for.
3 件のコメント
anil simsek
2020 年 5 月 6 日
I have Arduino code, I want to draw it instantly in matlab. Can you help me
参考
カテゴリ
Help Center および File Exchange で Arduino Hardware についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!