Go Down

Topic: Communication Arduino MatLab (Read 375 times) previous topic - next topic

Hi Everyone.
I have an Arduino 2560 Mega R3 , Arduino motorshield R3, stepper and a hall sensor.

I want that the Arduino sends data over the serial interface to MATLAB.
My Matlab code for that:
Code: [Select]
clear all;

%Create serial Port
arduino=serial('COM5','BaudRate',9600);

%Open serial Port
fopen(arduino);

while 1
    i=fread(arduino);
    fprintf('%d\n', i);
end

%Close serial Port
fclose(arduino);

%Delete serial Port
delete(arduino);


My Arduino code for that:
Code: [Select]
int sensor;
void setup()
{
   Serial.begin(9600);
  }

void loop()
{// this should simulate a sensor
   for(sensor=0; sensor < 100; sensor++){
         Serial.print(sensor);
   }
}


If someone of you can help me pls, i would be glad.  Thanks

Go Up