Edgetriggered pulse counter

You must not have tried very hard - here

And it's the first hit when I Google "arduino attachinterrupt"

...R