Rotary Encoder Quadrature (A/B 90° Phase) & 10 nF Hardware Debouncing
How does a simple mechanical volume knob know whether you turned it clockwise or counter-clockwise? Inside are TWO switches (CLK and DT) offset by 90°: turning CW makes A change before B, while CCW makes B change before A — and adding two 10 nF capacitors eliminates the contact bounce spikes that cause double-counting!
Hardware RC debouncing keeps interrupt service routines (ISRs) tiny and accurate even at fast knob spin speeds.
- Direction Rule: When Channel A (CLK) falls from HIGH to LOW, sample Channel B (DT) — if B is LOW, you turned CW; if B is HIGH, you turned CCW!
- Hardware Debounce: A 10 kΩ pull-up + 10 nF capacitor to GND creates a 0.1 ms RC low-pass filter that swallows microsecond switch chatter cleanly.
| Symbol | Component | Real-World Engineering Tip |
|---|---|---|
| ENC1 | KY-040 Incremental Rotary Encoder | Never put giant 10 µF capacitors on encoder pins — they slow edges down too much; stick to 10 nF–100 nF. |
Real-World Bench Scenario: Great for 3D printer menus, synth filter knobs, bench power supply voltage dials, and DIY macro pads.
Bench Challenge: Toggle CW vs CCW to watch Channel B shift 90° relative to Channel A, then switch 10 nF Hardware Debounce OFF vs ON to see raw contact bounce glitches disappear.