A rotary encoder is an electromechanical device that is used to monitor the angular position (angle) on a rotating axis. It converts monitored data into pulses which can then be processed by a microcontroller to determine the speed and position of the rotation of the axis.