volatile int count = 0 ;
and in the ISR do:
count ++ ;
When reading this variable outside the ISR you'll have to read it twice and check it hasn't changed inbetween since a variable of more than one byte will not be updated atomically, something like
int readCount ()
{
int first = count ;
int second = count ;
while (first != second)
{
first = second ;
second = count ;
}
return first ;
}
Or you can disable interrupts around the read of the variable.
Then to prevent problems with setting it to zero, you can always use the difference between successive readings:
int lastCount = 0 ;
void loop ()
{
...
...
int this_count = readCount () ;
int count_since_last = this_count - last_count ;
last_count = this_count ;
... use count_since_last ...
}