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
reading_inputted_data_from_four_pir_sensors_and_the_webcam.txt · Last modified: 2009/03/03 03:53 by lbarbour
Back to top
chimeric.de = chi`s home Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0