Filter löschen
Filter löschen

Get only one value from Arduino to Matlab using fscanf

2 Ansichten (letzte 30 Tage)
Han Son Go
Han Son Go am 20 Apr. 2017
Hello everyone, I want to send data from Arduino to Matlab and Matlab back to Arduino. Because I use interrupt so I have to use Serial seperately in Arduino and Matlab There are code I learn from the Internet to send data from Arduino to Matlab In Matlab:
arduino=serial('COM4','BaudRate',9600);
fopen(arduino);
y=fscanf(arduino,'%f');
fclose(arduino);
And in Arduino:
float temperature=9.100;
void setup()
{
Serial.begin(9600);
}
void loop()
{
Serial.print(temperature);
}
But when I run the program in Matlab, I saw that y had many different values, sometimes y was a char array. I just want to get one value, so how can I do that? Thank you very much!

Antworten (0)

Kategorien

Mehr zu MATLAB Support Package for Arduino Hardware finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by