![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
A polled Quadrature encoder Class
Diff: main.cpp
- Revision:
- 1:72e6e124a7e6
- Parent:
- 0:7c16b1d2f01e
--- a/main.cpp Tue Aug 30 19:52:34 2011 +0000 +++ b/main.cpp Tue Aug 30 20:03:36 2011 +0000 @@ -7,10 +7,13 @@ int main() { int oldEncPos = 0; int newEncPos = 0; + int oldEncRev = 0; + int newEncRev = 0; DigitalOut led1( LED1 ); + DigitalOut led2( LED2 ); - PolledQEI enc(p5, p6); + PolledQEI enc(p5, p6, p7); enc.setSampleFrequency(10000); led1 = 1; @@ -23,6 +26,11 @@ led1 = !led1; } + newEncRev = enc.rev(); + if (oldEncRev != newEncRev ) { + oldEncRev = newEncRev; + led2 = !led2; + } wait(0.01); } }