Mechanical encoders are essentially a series of switches. The code wheel contains contacts spaced evenly along its outer edge. Another contact is stationary and mounted on the encoder chassis. As the code wheel turns, it makes, then breaks contact with the code wheel contacts, one at a time. This making and breaking of a circuit generates a voltage pulse which can be read by a microcontroller.