Counting pulses with edge detection using digitalRead

You can use this method to detect edged using interrupt.