How to read an encoder and control a stepper motor without delay()

How can I do this?

Two approaches:

  1. 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.
  2. 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.