![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
testing encoder without function
encoder.cpp@0:e180c98a3437, 2021-11-01 (annotated)
- Committer:
- ea78anana
- Date:
- Mon Nov 01 15:39:50 2021 +0000
- Revision:
- 0:e180c98a3437
testing encoder
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ea78anana | 0:e180c98a3437 | 1 | #include "mbed.h" |
ea78anana | 0:e180c98a3437 | 2 | #include "QEI.h" |
ea78anana | 0:e180c98a3437 | 3 | |
ea78anana | 0:e180c98a3437 | 4 | QEI encoder (A0,A1,NC,2500); |
ea78anana | 0:e180c98a3437 | 5 | Serial pc(USBTX, USBRX); |
ea78anana | 0:e180c98a3437 | 6 | int counter = 0; |
ea78anana | 0:e180c98a3437 | 7 | int cur_state = 0; |
ea78anana | 0:e180c98a3437 | 8 | |
ea78anana | 0:e180c98a3437 | 9 | int main(void) { |
ea78anana | 0:e180c98a3437 | 10 | while(1){ |
ea78anana | 0:e180c98a3437 | 11 | counter = counter++; |
ea78anana | 0:e180c98a3437 | 12 | if( counter > cur_state){ |
ea78anana | 0:e180c98a3437 | 13 | cur_state = counter; |
ea78anana | 0:e180c98a3437 | 14 | printf("%d ", cur_state); |
ea78anana | 0:e180c98a3437 | 15 | }else if(counter < cur_state){ |
ea78anana | 0:e180c98a3437 | 16 | cur_state = counter; |
ea78anana | 0:e180c98a3437 | 17 | printf("%d ", cur_state); |
ea78anana | 0:e180c98a3437 | 18 | } |
ea78anana | 0:e180c98a3437 | 19 | } |
ea78anana | 0:e180c98a3437 | 20 | } |