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