Components / Sensors / Rotary encoder module (KY-040)
Sensors

Rotary encoder module (KY-040)

Knob that turns endlessly and gives clicks plus a push button.

Rotation steps and directionMeasures
20 detents per turn typicalRange
Two quadrature digital outputs plus switchInterface
5 VSupply voltage
ReviewedMade by GenericMPN KY-040Used in 42 projects
Get this part
In short

What is the Rotary encoder module (KY-040) and what is it used for?

Knob that turns endlessly and gives clicks plus a push button. Makers use it for menus, volume knobs.

How it works

Two switches close in a staggered (quadrature) pattern as the shaft turns, so the order of the pulses shows direction.

Key specifications

Sensor specValue
MeasuresRotation steps and direction
Range20 detents per turn typical
InterfaceTwo quadrature digital outputs plus switch
Supply voltage5 V

Pinout

CLKOutput A
DTOutput B
SWPush switch, LOW when pressed
+3.3 to 5 V for the pull-ups
GNDGround

How to use it

Read CLK and DT with interrupts or a library such as Encoder. Direction comes from which output changes first. Mechanical contacts bounce, so filter in software or with 100 nF capacitors to ground.

Applications

Alternatives

Buy at

Common questions

What is the Rotary encoder module (KY-040) used for?

In maker projects: menus, volume knobs.

How does the Rotary encoder module (KY-040) work?

Two switches close in a staggered (quadrature) pattern as the shaft turns, so the order of the pulses shows direction.

What voltage does the Rotary encoder module (KY-040) need?

5 V.

How do I connect the Rotary encoder module (KY-040) to an Arduino or ESP32?

Two quadrature digital outputs plus switch. Pins: CLK (Output A), DT (Output B), SW (Push switch, LOW when pressed), + (3.3 to 5 V for the pull-ups), GND (Ground).

What can I use instead of the Rotary encoder module (KY-040)?

AS5600 magnetic angle encoder and Incremental rotary encoder 600 PPR.