Plotting live data from Arduino in Matlab
5 次查看(过去 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 个评论
另请参阅
类别
在 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!