Hi Arduinos!
I am working on my project and got stuck at sending variables from Matlab to Arduino.
What I want to do is to send this value from Matlab: 255,100,0,100,175,300
and fill 6 variables in Arduino (which I will use for something later).
I understand I can use Serial.parseint to fill my variables, but it is not really working, and since I'm really new to programming I don't know where I made a mistake. Can you PLEASE help me?
Arduino code looks like this:
void setup()
{
int a=0;
int b=0;
int c=0;
int d=0;
int e=0;
int f=0;
Serial.begin(9600);
}
void loop()
{
if(Serial.available()>0) // if there is data to read
{
a=Serial.parseInt(); // read data
b=Serial.parseInt();
c=Serial.parseInt();
d=Serial.parseInt();
e=Serial.parseInt();
f=Serial.parseInt();
}
}
Matlab code:
data=['255,100,0,100,175,300'];
global s;
s=serial('COM4','BaudRate',9600);
fopen(s);
fprintf(s,data);
fclose(s);