Borrar filtros
Borrar filtros

Get only one value from Arduino to Matlab using fscanf

2 visualizaciones (últimos 30 días)
Han Son Go
Han Son Go el 20 de Abr. de 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!

Respuestas (0)

Categorías

Más información sobre MATLAB Support Package for Arduino Hardware en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by