How to send data from matlab R2013a to arduino uno and then send to Xbee pro s1?

1 view (last 30 days)
i am working on a project where i need to send some data from a PC to another, and I am trying to do it by Matlab-Arduino-Xbee. I have two ends. The receiving end is working as i have checked the receiving while sending from XCTU, but I cannot send data from matlab to arduino and then to xbee. the Matlab code is-
s = serial('COM7');
s.BaudRate=19200;
set(s,'Parity','none');
set(s, 'terminator', 'LF');
set(s,'Timeout',1);
fopen(s)
try
i=1;
while i<=1000
data(i) = fprintf(s,'100') ;
i=i+1;
end
catch me
fclose(s)
end
and the arduino code is -
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup() {
Serial.begin(19200);
while (!Serial) {
;
}
mySerial.begin(19200);
}
void loop() {
if (Serial.available()) {
mySerial.println(Serial.readString());
}
}
can anyone help me on my mistakes and suggest me the right way to do it?

Answers (0)

Categories

Find more on WSNs in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!