for 3 encoders
Embed:
(wiki syntax)
Show/hide line numbers
encoder.cpp
00001 #include "mbed.h" 00002 #include "QEI.h" 00003 00004 QEI encoder (A0,A1,NC,2500); 00005 Serial pc(USBTX, USBRX); 00006 int counter = 0; 00007 int cur_state = 0; 00008 00009 int main(void) { 00010 while(1){ 00011 counter = encoder.getPulses(); 00012 if( counter > cur_state){ 00013 cur_state = counter; 00014 printf("%d ", cur_state); 00015 }else if(counter < cur_state){ 00016 cur_state = counter; 00017 printf("%d ", cur_state); 00018 } 00019 } 00020 }
Generated on Thu Jul 14 2022 16:31:36 by
1.7.2