Everything here is licensed under these terms:

Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.

This license lets others remix, tweak, and build upon the work even for commercial reasons, as long as they credit me and license their new creations under the identical terms. This license is often compared to open source software licenses. All new works based on this will carry the same license, so any derivatives will also allow commercial use.

If you create derivative works, credit me by including a link to this web page:

Arduino Quadrature Encoder Library

An Arduino library for reading multiple quadrature encoders. Each is instantiated as an object, so usage is extremely simple:

#include "Quadrature.h"

Quadrature myencoder1(9, 10);  //  Connected to pins 9 and 10
x = myencoder1.position();

The library includes support for enabling and disabling minimum and maximum values (e.g. to make a volume control that goes from 0-9) and for changing the current position (e.g. to reset all settings back to defaults).

The library uses the TIMER2 interrupt service routine to read the encoders fast enough to avoid losing steps for encoders being turned by humans. TIMER2 settings may need to be changed in order to read encoders on motors or other mechanically-driven mechanisms; this is a likely future enhancement.


To install, copy the zip file to your Arduino installation’s hardware/libraries directory, then unzip it. Once installed, you can view sample sketches from your Arduino console’s File / Sketchbook / Examples / Library-Quadrature menu.

Free Circuits

Circuits and board layouts are on a separate page.