I now know how to send simple data fram matlab to arduino but the problem now is that I don't know how to separate the commands/strings from matlab in arduino. i. e.
s1 = serial('COM3', 'BaudRate', 9600, 'Parity', 'none', 'DataBits',
fprintf(s1, 'Hello World!') - or if I'm going to control 4 motors:
fprintf(s1, 100(motorspeed), 1(as in motor no. 1), 0(as in direction 1 of 2 on motor 1)) and perhaps
fscanf(s1) - if I'm going to read something from the arduino back to matlab
In Arduino - I know the setup() and loop() methods, this is just some of the code:
info = Serial.read();
Serial.println('I want to send something back to matlab');
I can for instance send the char '8' from matlab to arduino and let the motors run when char info detects the char '8' but that solves nothing because then all my motors will run and I will not be able to control them separately. I'm thinking on splitting the string I get from matlab and separate the words/integers to each motor but I don't know if it's possible yet.