필터 지우기
필터 지우기

Matlab Arduino Hand Shake

조회 수: 1 (최근 30일)
Zack Bayhan
Zack Bayhan 2014년 11월 8일
Hello everyone, I'm trying to get my arduino up and running so that I can use matlab to control it. I followed the instructions in the following video,
https://www.youtube.com/watch?v=ymWXCPenNM4
I mistakenly entered the wrong port, and as expected an error appeared stating that I had to pick from com1 or com4, the arduino is set up on com4 so I changed the variable and ran the script again. This time I get an error that only com1 was available. I typed instrfind into the command window and found that com port 4 is closed. How do I go about turning it on? Thanks Zack
function [S, flag] = ArduinoHandShake(comPort)
% Initialize the serial port communication between matlab and Arduino
flag=1;
s=serial(comPort);
set(s, 'DataBits',8);
set(s, 'StopBits',1);
set(s, 'BaudRate', 9600);
set(s, 'Parity', 'none');
fopen(s);
a='b';
while (a~='a')
a=fread(s,1,'uchar');
end
if (a=='a')
disp('serial read');
end
fprintf(s,'%c','a');
mbox=msgbox('serial communication setp.'); uiwait(mbox);
fscanf(s,'%u');
end

답변 (0개)

카테고리

Help CenterFile 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!

Translated by