timeout for a function.

hi,
i am using a finger print sensor, and to see if a finger is valid it waits until a finger is on the sensor.
but i want to do something if this function doesnt end after about 20 sec. (if nobody puts a finger)
i thought about timers, timeout, thread, and timed action but it seems that nothing can work cause the function check_a_finger() is blocking...

i wanted to do something like this:
set_a_time_out(20000);
check_a_finger();

if time out before check a finger is finish call a function.
else if check_a_finger end before, stop the timeout...

Any ideas on how to do this?
i hope you have some wonderful ideas;)
i am so desesperate that i think a bout an external i2c alarm...

You need to rewrite the check_a_finger() function to be non-blocking or to handle the timeout itself.

Post the check_a_finger function (and the rest of your code) it depends what you are doing in this function

Look at the blink without delay example and at the use of finite state machines in the playground.

Mark

yeah i wanted to rewrite check_a_finger but it's not possible it's embed in the sensor's own micro :~

Does the sensor have any method by which it can be reset ?

yeah i wanted to rewrite check_a_finger but it's not possible it's embed in the sensor's own micro

You need to post your Arduino code and a link to the fingerprint reader. The check_a_finger function should not block waiting for hardware.

hi ,
i was stupid i misunderstood the code th function was rewritable, and i include a timeout in it! it works now like i want.
Thanks all of you!