DIY ELECTRONICSTR

← All parts

Rotary Encoder (KY-040)

Control

Endlessly turning knob that reports a step and its direction at every click; pressing it down also works as a button. Handier than a potentiometer for menu navigation, volume or temperature setting, and counters. The direction comes from which of the two signals on CLK and DT changes first; to avoid missing steps, use interrupt pins (2 and 3 on an Uno) or the Encoder library. Turn on INPUT_PULLUP for the SW pin.

Specifications

Type
Incremental (quadrature) encoder + push switch
Steps
20 clicks (detents) per turn
Rotation
Endless (360°)
Operating voltage
3.3 - 5V
Pins
CLK, DT, SW, + (VCC), GND
Pull-ups
10 kΩ on CLK and DT (use INPUT_PULLUP for SW)
Library
Encoder (Paul Stoffregen) or interrupts

Shop prices

Prices read from the shops' pages on 22 October 2026. Prices and stock may have changed since; check at the shop before you buy.

Projects with this part

In the app, tick off every wire, match the parts to your inventory and pick up where you left off.

Build it step by step in the app