Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dan9thsense
committed
Jun 8, 2012
1 parent
d9a7135
commit cb73707
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//Encoders | ||
|
||
#include <Encoder.h> | ||
|
||
// Change these two numbers to the pins connected to your encoder. | ||
// Best Performance: both pins have interrupt capability | ||
// Good Performance: only the first pin has interrupt capability | ||
// Low Performance: neither pin has interrupt capability | ||
Encoder myEnc(5, 6); | ||
// avoid using pins with LEDs attached | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
Serial.println("Basic Encoder Test:"); | ||
} | ||
|
||
long oldPosition = -999; | ||
|
||
void loop() { | ||
long newPosition = myEnc.read(); | ||
if (newPosition != oldPosition) { | ||
oldPosition = newPosition; | ||
Serial.println(newPosition); | ||
} | ||
} |