It is amazing how many Arduino programmes for decoding rotary encoders start with something like: “I looked at all the available rotary encoder sketches and none of them met my needs, so I have ...
Arduino sketch that reads a quadrature rotary encoder on interrupts and sends its position (in degrees) over OSC via an Ethernet shield. Despite the name, output is OSC, not serial.
// CLOCK, DATA and BTN, as GPIO numbers. // Uno: 2, 3, 4. ESP32: 25, 26, 27. ESP32-S3: 4, 5, 6. Pico: 13, 14, 15.