/****************************************************************************** * quadrature_two_encoders * Keith Neufeld * July 4, 2008 * * Read and decode two quadrature rotary encoders. * * Demo system has encoders connected to digital pins 8/10 and 9/11. * ******************************************************************************/ #include "Quadrature.h" //Your standard inclusion of the library file /* * The following undefines are needed due to conflict between different header files. This is * one of the drawbacks of using libraries written by other people. They are often * created with a specific purpose in mind and may not be applicable to all * situations. */ #undef int #undef abs #undef double #undef float #undef round /* For those who are familiar with object oriented programming (OOP), the author of this library * created a Quadrature class with a position function. For those who are unfamiliar with OOP, what * means is that in order to use the functionality provided by Quadrature.h, you must first instantiate, * or create a Quadrature instance. Think of it as declaring a variable, except with greater complication. * You must give a set minimum and a set maximum. After you've created an instance of the Quadrature class, * you can ask the Quadrature instance "questions". For example, quad1.position() returns the position of * that particular Quadrature instance. */ Quadrature quad1(2, 3); void setup() { Serial.begin(9600); quad1.minimum(0); quad1.maximum(1023); } void loop() { //This updates the serial monitor every tenth of a second. Serial.println(quad1.position()); delay(100); }