Using interrupts for PULSE width detection.