概述
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
clear;clc;
global s1;%%//s1为光电测速传感器返回值
global s2;
s1=serial('COM4');
set(s1,'BaudRate',38400);
s1.BytesAvailableFcn=@dianjibiaocan_receiveFcn_3;
s1.BytesAvailableFcnMode='byte';
% s1.BytesAvailableFcnCount=1;
s1.ReadAsyncMode='continuous';
fopen(s1);
s1.status
global loopCount;
global CountTimes;
global BackTime;
global velocity;
global distance;
global a;
global T;
global PeriodTime;
PeriodTime=0.015;
%%----------------主函数(执行循环)使程序不断运行--------------
loopCount=1;
BackTime=[];
CountTimes=[];
velocity=[];
distance=[];
T=0;
disp('startedn');
power=240;
while 1
tstart=tic;
tused=0;
switch loopCount
case 50
disp('The sensor has send datas back for 50times')
disp(a(loopCount-1))
disp(velocity(loopCount-1))
case 100
disp('The sensor has send datas back for 100 times ')
disp(a(loopCount-1))
disp(velocity(loopCount-1))
break
otherwise
end
% /*********空执行定时延时程序*********/
while (tused
tused=toc(tstart);
end
end
b=0;
fprintf(s1,'%dn',b);
fclose(s1);
delete(s1);
clear s1;
最后
以上就是爱撒娇指甲油为你收集整理的matlab与arduino通信,【arduino】Arduino UNO智能小车和Matlab串口数据通信的全部内容,希望文章能够帮你解决matlab与arduino通信,【arduino】Arduino UNO智能小车和Matlab串口数据通信所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复