How to check for input for parallelport again and again?

Hi
I am doing my image processing project using matlab with external hardware attached using parallel port. I am building a automatic door security system. In which a user has to stand infront of a camera and press a button. When the button is pressed the camera take pic of the user and then on a computer system placed by side runs a matlab code which identifies the person. If it identify it ,it sends some specific output through parallel port on microcontroller. if it doesn't it send some other output on parallel port.
my question is ...I want my project to work in such way that..When i press the button for taking picture through camera the button should be connected to paralel port...and upon pressing it send either '1' input to matlab through paralel port .On matlab i want to implement some function that continously check for input from parallel port...and when it recieve '1' it automatically capture picture from the camera attached to it and perform the rest of the code. If it does recieve '0' then it keep checking parallel port until the value become'1' for executing code. In c we used to use goto statement for continously monitoring a port but in matlab we can't use it...I just want to know how can i implement such monitor function in matlab...please help me as this is my final project(note that camera is interfaced with matlab and it does capture images from matlab command not from button the button only use for the purpose of giving matlab input for monitoring the input) Please help me i shall be very grateful. yasir

Answers (1)

The simplest, but least elegant solution would be a while loop
stopFlag = false;
while true
% code that checks the parallel port
% Check to check if you need to stop
if stopFlag
break;
end
pause(0.01); % There is probably no reason to check more frequently then every 10 ms.
end
A better way would be with a timer
doc timer

Categories

Asked:

on 28 Aug 2011

Community Treasure Hunt

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

Start Hunting!