Home Proto-all Product Rotary Encoder Module — CLK/DT/SW Output, 20 Detents, Arduino Compatible (KY-040)
Skip to product information
1 of 3

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.

Regular price $5.12 USD
Sale price $5.12 USD
Save -37% Sold out
Taxes included. Shipping calculated at checkout.

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.

visa
View full details
Quality Guarantee Certified components
100% Safe Checkout SSL encrypted payment
Fast Shipping Worldwide delivery
90-Day Returns Hassle-free policy