MATLAB Code
%Basic Comm
s = serial('COM8');
set(s,'BaudRate',9600);
set(s,'DataBits',8);
set(s,'StopBits',1);
fopen(s);
fprintf(s,'*IDN?')
vid = videoinput('winvideo',1,'RGB24_320x240');
preview(vid);
figure
hold on
data = [];
pirOneStore =[];
pirTwoStore = [];
pirThreeStore = [];
pirFourStore = [];
increment = [];
for p = 1:1
hold on
startlist = [];
pirOne =[];
pirTwo =[];
pirThree =[];
pirFour =[];
axis([0 100 0 50])
for i = 1:100
startlist = [startlist i];
out = fscanf(s, '%d');
pirOne =[pirOne out];
pirOneStore = [pirOneStore out];
subplot(4,1,1);
axis([0 100 0 50])
plot(startlist, pirOne)
axis([0 100 0 50])
out = fscanf(s, '%d');
pirTwo =[pirTwo out];
pirTwoStore = [pirTwoStore out];
subplot(4,1,2);
axis([0 100 0 50])
plot(startlist, pirTwo);
axis([0 100 0 50])
out = fscanf(s, '%d');
pirThree =[pirThree out];
pirThreeStore = [pirThreeStore out];
subplot(4,1,3);
axis([0 100 0 50])
plot(startlist, pirThree);
axis([0 100 0 50])
out = fscanf(s, '%d');
pirFour =[pirFour out];
pirFourStore = [pirFourStore out];
subplot(4,1,4);
axis([0 100 0 50])
plot(startlist, pirFour);
axis([0 100 0 50])
drawnow
if(p == 1 && i == 1)
tic;
else
increment = [increment toc];
tic;
end
%if(mod(i,3) == 0)
data = [data getsnapshot(vid)];
%end
end
clf
end
fclose(s)
delete(s)
clear s
Back to top