Page 1 of 1

COUNTER

Posted: Fri Jun 01, 2007 9:19 am
by wayne millard
Can you do a count of a button press in a main routine without it being reset back to zero.

Because i have a main routine and a count subrutine. being trigged by port b7 as interupt. The problem is the i can get the counter to count then get stuck in the count routine. or i set the loop to loop on button press it counts but when it exits back to the main routine the count gets reset. :)

Posted: Fri Jun 01, 2007 9:33 am
by Benj
Hello

Make the count variable global. That is define the variable at the start of the program in the main variables window. Then whenever you use it it should keep its last assigned value. Make sure that there is a initialisation of the variable at the beginning of the program or you could start counting from an undetermined number.