Signals and controls
Mechanical rotary encoder
Turn a knob indefinitely to adjust a setting.
What it does
Two contacts switch in quadrature. The order of state changes reveals direction; the button is a separate input.
Connections and compatibility
Use the A/CLK and B/DT outputs with pull-ups and a common ground. A bare encoder common pin goes to ground. Module pin labels and built-in resistors vary.
Choosing one
A KY-040-style incremental module is inexpensive. Count valid transitions first, then calibrate how many make one detent on your unit.
Common mistakes
Polling too slowly loses steps. A single contact edge can bounce; decoding complete valid sequences is more reliable.
Use it in a tutorial
- Using rotary encoders — Decode a mechanical knob’s direction and count complete quadrature cycles without mistaking every bounce for a turn.