![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
testing encoder without function
Diff: encoder.cpp
- Revision:
- 0:e180c98a3437
diff -r 000000000000 -r e180c98a3437 encoder.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/encoder.cpp Mon Nov 01 15:39:50 2021 +0000 @@ -0,0 +1,20 @@ +#include "mbed.h" +#include "QEI.h" + +QEI encoder (A0,A1,NC,2500); +Serial pc(USBTX, USBRX); +int counter = 0; +int cur_state = 0; + +int main(void) { + while(1){ + counter = counter++; + if( counter > cur_state){ + cur_state = counter; + printf("%d ", cur_state); + }else if(counter < cur_state){ + cur_state = counter; + printf("%d ", cur_state); + } + } +} \ No newline at end of file