Try detecting rising and falling edge