This page covers the purpose, scope, repository layout, supported platforms, and metadata for the RotaryEncoder Arduino library. For architectural details of the RotaryEncoder class itself, see Core Library Architecture. For installation and wiring, see Getting Started Guide.
The RotaryEncoder library decodes quadrature signals from a mechanical rotary encoder and maintains a running counter position. Each physical "notch" on the encoder produces two out-of-phase pulse trains on two digital input pins; the library interprets the phase relationship between these signals to determine direction and magnitude of rotation.
The library is designed to be used in the Arduino ecosystem across a wide range of microcontroller families, relying exclusively on Arduino core APIs rather than direct register manipulation.
Key capabilities:
| Capability | Description |
|---|---|
| Quadrature decoding | Decodes 4-state pulse patterns from two encoder pins |
| Position tracking | Maintains a signed integer position counter |
| Direction detection | Reports CLOCKWISE, COUNTERCLOCKWISE, or NOROTATION |
| Speed measurement | getMillisBetweenRotations() and getRPM() for velocity |
| LatchMode selection | Configurable step resolution (FOUR3, FOUR0, TWO03) |
| Interrupt and polling | Works with attachInterrupt() ISRs or repeated tick() calls |
| Debounce support | Optional software debounce via setDebounceMillis() |
| Software-only mode | Constructor without pins for custom signal routing |
Sources: library.properties1-9 README.md1-24 CHANGELOG.md1-56
| Field | Value |
|---|---|
| Name | RotaryEncoder |
| Version | 1.6.0 |
| Author | Matthias Hertel |
| Maintainer | Matthias Hertel, http://www.mathertel.de |
| Category | Signal Input/Output |
| Architectures | * (all) |
Sources: library.properties1-9
The repository is organized into a library core, example sketches, CI configuration, and documentation.
Repository structure diagram:
Sources: library.properties1-9 README.md1-24 CHANGELOG.md1-56
The two files in src/ form the entire library implementation.
Component and class diagram:
Sources: library.properties5-6 CHANGELOG.md8-24
The library supports two primary integration patterns:
| Pattern | Mechanism | Best For |
|---|---|---|
| Polling | Call tick() repeatedly in loop() | Simple sketches, low encoder speed |
| Interrupt-driven | Attach tick() to pin change ISR via attachInterrupt() | Responsive UI, fast rotation, concurrent tasks |
For detailed guidance on each pattern, see Usage Patterns and Examples.
| Version | Key Changes |
|---|---|
1.5.0 | Added getMillisBetweenRotations(), getRPM(), LatchMode::TWO03, ESP8266/Every board support |
1.5.1 | Fixed attachInterrupt() to use digitalPinToInterrupt() for UNO compatibility |
1.5.2 | Minor CI integration fixes |
1.6.0 | Software-only constructor (RotaryEncoder(LatchMode)), debounce support (setDebounceMillis()), atomic ISR access, ESP32 fixes |
For full details, see Version History and Changelog.
Sources: CHANGELOG.md1-56
The library declares architectures=* in library.properties9 meaning it targets all Arduino-compatible platforms. The CI pipeline validates builds against AVR (UNO), NANO Every, ESP8266, and ESP32 board targets.
For platform-specific details including IRAM_ATTR requirements and AVR pin-change interrupt alternatives, see Platform Support and Compatibility.
Sources: library.properties9 CHANGELOG.md17-21