Matlab Arduino Hand Shake

7 visualizaciones (últimos 30 días)
Zack Bayhan
Zack Bayhan el 8 de Nov. de 2014
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

Respuestas (0)

Categorías

Más información sobre MATLAB Support Package for Arduino Hardware en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by