Quadrature encoder
A sensor producing two square waves a quarter-period apart, so both position and direction of rotation can be read from two digital inputs.
The channels are called A and B. Turn one way and A leads; turn the other and B does, so whichever edge came first gives the direction. Counting all four edges per cycle yields four times the encoder's nominal resolution. Many encoders add a third channel, index or Z, which pulses once per revolution and provides an absolute reference point.
Decoding in software via GPIO interrupts is fine for a front-panel knob, not for a motor doing several thousand rpm. That is why most microcontroller timers offer an encoder mode that counts up and down in hardware without waking the CPU. Mechanical rotary knobs also bounce, and naive decoding then jitters back and forth between two positions.