![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
encoder
encoder.cpp
- Committer:
- ea78anana
- Date:
- 2021-10-31
- Revision:
- 1:36b9ba5a34ff
- Parent:
- 0:4d7336a951bd
File content as of revision 1:36b9ba5a34ff:
#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 = encoder.getPulses(); if( counter > cur_state){ cur_state = counter; printf("%d ", cur_state); }else if(counter < cur_state){ cur_state = counter; printf("%d ", cur_state); } } }