How can I do this?
Two approaches:
- use a state machine: this requires saving the previous state of the pins and determine the rotation based on the previous state + current state. Coupled with an array, this is incredibly fast.
- use an isr: so you don't miss a pulse.
When you combine the two, you can read the rotation easily into thousands of pulses per second.