Search wiring.org.co:

Libraries

## Encoder

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.

Encoder()
Class for manipulating encoders attached to the Wiring hardware.

attach()
Attaches an encoder variable to an encoder connected to a pin.

detach()
detaches an encoder variable from a pin.

read()
Reads the encoder position or angle.

write()
Sets the encoder position or angle.

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