Use an encoder example, D8 connect to the channel A, D9 connect to the channel B to receive the interrupt: