switched from using pulseIn to the use of interrupts