Exit function after specified time
hi,
im not sure if asked before, wondering if break function if function doesn't execute in 6 seconds.
basically function running calculate time takes magnet pass once on reed switch:
i want function stop executing if takes longer 6 seconds indicate speed 0 in rest of code. need use interrupt or there way of achieving goal?
thanks in advance
im not sure if asked before, wondering if break function if function doesn't execute in 6 seconds.
basically function running calculate time takes magnet pass once on reed switch:
code: [select]
void tripuino::rech(unsigned long *timestart, unsigned long *timeend){
while (digitalread(3) == high){
}
*timestart = millis();
while (digitalread(3) == low){
}
while (digitalread(3) == high){
}
*timeend = millis();
}i want function stop executing if takes longer 6 seconds indicate speed 0 in rest of code. need use interrupt or there way of achieving goal?
thanks in advance
you should move timestart declaration before first while loop. then, in each while loop, check condition , check (millis()) minus start time less 6 seconds.
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Exit function after specified time
arduino
Comments
Post a Comment