ok, now i got another problem.
i want to sent not only numbers to arduino with matlab.
i want to send following code:
p7m45g
this means: servo on pin 7 with 45 degree
how can i send this with matlab?
my code is:
%% Arduino Servo Controller
arduino = serial('COM3','BaudRate',9600); % Set ComPort
fopen(arduino);
pause(0.1) % this is very important! arduino needs a little time to initialise the fopen command, because it resets it!
fprintf(arduino,'%s','p7m20g')
fclose(arduino);
delete(arduino)
clear arduino
but it doesnt work, any ideo?
---moe
edit:
ok, solved it.
you have to set the pause after fopen longer.
a pause of 1.7 seconds worked
is there any other way to solve this?
%% Arduino Servo Controller
arduino = serial('COM3','BaudRate',115200); % Set ComPort
fopen(arduino);
pause(1.7) % this is very important! arduino needs a little time to initialise the fopen command, because it resets it!
fprintf(arduino,'%s','p7m45g') %servo on pin 7 to 45 degree
fprintf(arduino,'%s','p6m135g') % servo on pin 6 to 135 degree
fclose(arduino);
delete(arduino)
clear arduino