Rotary encoder (KY-040) (EC11)
KY-040 incremental rotary encoder · 20 detents per turn, 1 quadrature cycle per detent · CLK/DT pulled up 10 kΩ to + · SW to GND when pressed (no pull-up fitted) · contact bounce on

Try it on the benchThe lab drops it on an empty bench and opens its datasheet card.
Typical part: KY-040 rotary encoder module (EC11-type, 20 detents)
Pins
- GND
- +
- SW
- DT
- CLK
Ratings and limits
| Signals | CLK (A) and DT (B): 2-bit Gray code, 90° apart; one full cycle (4 edges) per detent; both high at rest |
|---|---|
| Pull-ups | 10 kΩ on CLK and DT to +; the SW pull-up is usually not fitted (use INPUT_PULLUP) |
| Switch | SW to GND while the shaft is pressed |
| Bounce | a few ms of contact bounce on each edge: debounce in software (ignore edges closer than about 1–2 ms) or with RC filters |
| Supply | + 3.3–5 V (only the pull-ups use it) |
How to use it
Turn = count steps (the direction comes from which signal changes first), press = select. Read it with interrupts on CLK (or both pins) and a small debounce, or poll every millisecond.
More in switches & protection
- Fuse
- Relay
- Toggle switch
- Changeover switch
- Push button
- Wall switch
- AC breaker
- RCD (30 mA)
- DC breaker
- Resettable polyfuse
Sources: ALPS EC11 series data; KY-040 module schematic (10 kΩ pull-ups on CLK and DT, R1 for SW often unpopulated).