A rotary encoder is a digital input device used to measure angular rotation and direction. It does this by sending two out-of-phase pulse trains. Direction is determined by which pulse arrives first.