Rotary Encoder Module — CLK/DT/SW Output, 20 Detents, Arduino Compatible (KY-040)
Rotary Encoder Module CLK/DT/SW Output, 20 Detents, Arduino Compatible (KY-040)
Compatible JST cables for sensors and modules — secure & reliable. Shop now.
Couldn't load pickup availability
Rotary Encoder Module — CLK/DT/SW Output, 20 Detents, Arduino Compatible (KY-040)
This rotary encoder module (KY-040 compatible) is an incremental position sensor that reports the direction and amount of shaft rotation, plus a pushbutton press when the shaft is depressed. It's the essential input device for Arduino menu navigation, volume control, and any application requiring continuous rotary input without a mechanical stop. The module includes a built-in pull-up resistor on the SW pin and a 5-pin header for direct connection to Arduino.
Module Specifications
- Type: Incremental rotary encoder (no absolute position)
- Detents per Revolution: 20 (20 clicks = 1 full rotation)
- Outputs: CLK (A), DT (B), SW (pushbutton)
- Operating Voltage: 3.3V – 5V DC
- Pushbutton: Active LOW (shaft press)
- Rotation: Continuous (no mechanical stop, infinite turns)
- PCB Dimensions: 26 × 20mm
- Shaft Height: 30mm total
5-Pin Header Connections
- GND: Ground
- +: VCC (3.3V or 5V)
- SW: Pushbutton output (active LOW) → Arduino digital input
- DT: Direction output (B phase, 90° lag) → Arduino digital input
- CLK: Clock output (A phase) → Arduino digital input
Direction Detection Logic
- Clockwise (CW): When CLK changes state, DT ≠ CLK
- Counter-Clockwise (CCW): When CLK changes state, DT = CLK
- Compare CLK and DT states on each CLK edge to determine rotation direction
Arduino Wiring
- GND → Arduino GND | + → 5V
- CLK → D6 | DT → D5 | SW → D7 (with INPUT_PULLUP)
Typical Applications
- LCD menu navigation: Scroll through menu items (rotate) and select (press) — the most common use case
- Volume / parameter control: Adjust audio volume, motor speed, or any continuous parameter
- Stepper motor control: Rotate encoder to drive stepper motor in same direction and amount
- Odometer / distance measurement: Attach wheel to shaft and count pulses for distance
- Position tracking: Track relative position from power-on reference point
Package Contents
- 1 × Rotary encoder module (KY-040 compatible) with 5-pin header
20 detents, infinite rotation, CLK/DT/SW outputs — the KY-040 rotary encoder module is the go-to input device for Arduino menu navigation, volume control, and continuous rotary position sensing.

Blog posts
View all-
IC Chips & Discrete Components Express Shipping...
Shipping IC chips and discrete electronic components internationally requires more than choosing a carrier. ESD-safe packaging, correct HS codes, accurate customs declarations, and carrier selection for your destination all determine...
IC Chips & Discrete Components Express Shipping...
Shipping IC chips and discrete electronic components internationally requires more than choosing a carrier. ESD-safe packaging, correct HS codes, accurate customs declarations, and carrier selection for your destination all determine...
-
From Prototype to Mass Production — How to Scal...
Scaling from prototype to mass production is the most critical transition in a hardware product's lifecycle. The sourcing strategy that works for 10 prototype boards — cut tape, spot pricing,...
From Prototype to Mass Production — How to Scal...
Scaling from prototype to mass production is the most critical transition in a hardware product's lifecycle. The sourcing strategy that works for 10 prototype boards — cut tape, spot pricing,...
-
ISO 9001 Electronic Component Distributor — Wha...
ISO 9001:2015 certification is the most widely recognized quality management standard in the world — but what does it actually mean when an electronic component distributor claims to be ISO...
ISO 9001 Electronic Component Distributor — Wha...
ISO 9001:2015 certification is the most widely recognized quality management standard in the world — but what does it actually mean when an electronic component distributor claims to be ISO...