How can I connect Arduino with matlab if the entities are wireless?
조회 수: 2 (최근 30일)
이전 댓글 표시
I have two laptops, Laptop1 is where the arduino is connected to (with a transmitter), and Laptop2 is where the receiver is, thus, the wireless connection.
I would like to send a character or string from arduino(Laptop1) to matlab(Laptop2). Please note I am using a transmitter and receiver for this.
The receiver is connected in my COM10. Is this the right code for decoding the string sent by Arduino? Or are there things I need to change, because I keep getting an error message that says " Warning: Unsuccessful read: A timeout occurred before the Terminator was reached. "
global a;
a = serial('COM10','BaudRate',9600); %create serial communicationobject on port COM10
fopen(a);
meas = fscanf(a)
댓글 수: 0
답변 (1개)
David Sanchez
2014년 1월 21일
Check for any bytes stored in the buffer with the BytesAvailable option:
a = serial('COM10','BaudRate',9600);
fopen(a);
if a.BytesAvailable
meas = fscanf(a);
end
This way you only read when there is something to be read. Make sure the sender and receiver have the same configuration
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 MATLAB Support Package for Arduino Hardware에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!