The Wiring Encoder library allows for easily reading and writing a position or angle from an encoder.

The encoders are sensors used to track the position or rotation rate of a shaft. Encoders generate pulses when moved, on each pulse triggering an event on the Wiring I/O board, for this reason the phaseA pin of an encoder can only be connected to a Wiring pin capable of generating external interrupts. The Encoder library works on External interrupt pins.

On Wiring v1 boards the external interrupts capable pins are: 0, 1, 2, 3, 36, 37, 38 and 39 named EI0, EI1, .. EI7 respectively
On Wiring S board the external interrupts capable pins are: 2, 3 and 18 named EI0, EI1 and EI2 respectively.


Class for manipulating encoders attached to the Wiring hardware.

Attaches an encoder variable to an encoder connected to a pin.

detaches an encoder variable from a pin.

Reads the encoder position or angle.

Sets the encoder position or angle.

Returns whether or not en encoder is attached to a pin.