Matlab Arduino Hand Shake

7 ビュー (過去 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 Center および File ExchangeMATLAB 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