Arduino quadrature encoder library.  Implements an efficient interrupt based algorithm based off the here, http://letsmakerobots.com/content/how-use-quadrature-encoder