The KY-040 is a mechanically actuated incremental rotary encoder that uses internal mechanical contacts to generate digital quadrature (A/B) signals. It provides reliable rotation direction, step counting, and a built-in push button, making it ideal for menus, value adjustment, and navigation controls.
The encoder outputs quadrature signals (A and B) with a 90° phase difference, allowing your microcontroller to determine both rotation direction (clockwise or counter-clockwise) and movement steps. Unlike a potentiometer, the KY-040 does not have rotation limits – it can be turned continuously. The integrated momentary push switch (SW) is typically used for selection, confirmation, or resetting values.
Features / Specs
- Board Model: KY-040
- Encoder Type: Incremental Rotary Encoder
- Encoder Mechanical Form Factor: EC11
- Encoder Operating Principle: Mechanical Contacts
- Rotation Range: 360° Continuous Rotation
- Pulses Per Revolution: 20
- Supply Voltage: 5VDC
- Outputs: Quadrature A/B Outputs / Push Button Output
- Output Signal Type: Digital square wave same logic level as supply voltage
- Notable Features: Built-in momentary push button
- Header Pin Pitch: 2.54mm
- Dimensions: ~(26.2mm x 19.3mm x 30.1mm)
- Mounting Hole Diameter: ~2.9mm
- Mounting Hole Spacing (Center to Center): ~16.9mm
Operational Overview
The KY-040 is an incremental rotary encoder that converts mechanical rotation into digital signals which a microcontroller can interpret. When the shaft is rotated, the encoder generates two digital output signals, Channel A and Channel B. These signals are square waves with a 90° phase difference (quadrature). By observing which signal changes state first, the microcontroller can determine the direction of rotation:
- A leads B – clockwise rotation
- B leads A – counter-clockwise rotation
Each transition of these signals represents a step, allowing the system to count how far the knob has been turned. Because the KY-040 is incremental and not a potentiometer, it has no fixed start or end position and can rotate continuously. The module also includes a momentary push button (SW) that is activated by pressing the encoder shaft. This provides a third digital output, typically used for actions such as select, confirm, or reset.
In operation:
- Rotation produces A and B pulse signals.
- The MCU compares the A/B signal sequence to determine direction.
- Pulses are counted to track relative movement.
- The push button provides an additional user input.
Pin Description
- GND-> Ground
- +-> Supply Voltage (5VDC)
- SW-> Push Button Output
- DA-> Encoder Channel B Output
- CLK-> Encoder Chanel A Output



