1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| s = serial('COM7');
%get(s);
%set(s,'BaudRate',9600);
fopen(s);
x=1;
while x
xD=fread(s,1)
if xD > 128
xG=fread(s,1)
if xG > 192
yD=fread(s,1)
if yD >64
yG=fread(s,1)
if yG >96
temp=0;
end
else
temp=fread(s,1)
end
else
for i=1:2
temp=fread(s,i)
end
end
else
for i=1:3
temp=fread(s,i)
end
end
%%%
X=(xD-128)+[32*(xG-192)]
Y=(yD-64)+[32*(yG-96)]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% mon problème est la j'aimerai obtenir une courbe de X en fonction du temps (avec des points liés)
% cela ne marche pas:
t=now
plot (X,now,'-');
x=1;
end
fclose(s)
delete(s)
clear s |
Partager