Raspberry Pi practice problem · Buttons & input
Encoder cursor
MediumBudget $11Python · gpiozero
A rotary encoder (+ to 3.3 V, CLK on GPIO17, DT on GPIO18, 20 clicks per turn) and four LEDs on GPIO5, 6, 13, 19 (positions 0–3).
Exactly one LED is lit: the cursor. It starts at position 0 (GPIO5); each clockwise click moves it one position up, each anticlockwise click one down, wrapping around at both ends (3 → 0 and 0 → 3).
The test turns the knob to 36° at 1 s (2 clicks), to 90° at 2.5 s (3 more) and to −18° at 4 s (6 back).