Go Down

Topic: Communication Arduino MatLab (Read 392 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
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy