serial port reading.

1 view (last 30 days)
vijil viswam
vijil viswam on 29 Feb 2012
Here i submit a matlab program, which read ASCII values from a serial port to which an arduino board is connected.
for i = 0: 10
fclose(instrfindall); %close all serial comms
s=serial('COM25','BaudRate',9600); %start serial port to arduino
fopen(s); %open port
out = fgets(s); %read data from arduino, which waited until start
disp(out) %display arduino data
fclose(instrfindall);
end
The program read data successfully,but the problem is, its can't read data synchronously from arduino output port(COM25).(ie, some line of data is missing). kindly give me a solution for this problem and kindly give me a correct code also.

Accepted Answer

Walter Roberson
Walter Roberson on 29 Feb 2012
Do not continually close and open the serial port.
The default for serial ports is to read asynchronously. You have to change the serial port properties to read synchronously.
You have not changed your serial port terminator character, as is needed for arduino. See the MATLAB File Exchange contribution that shows a GUI for interacting with arduino devices.

More Answers (0)

Categories

Find more on MATLAB Support Package for Arduino Hardware 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!