encoder library
main.cpp
- Committer:
- Yamanobe
- Date:
- 2021-05-30
- Revision:
- 1:5dde31466ecb
File content as of revision 1:5dde31466ecb:
#include "mbed.h" #include "Encoder.h" //#include "core_cm3.h" Encoder encoder(A0, A1); Encoder encoder2(A2, A3); Serial pc(USBTX,USBRX); int main() { /*NVIC_SetPriority(EINT0_IRQn,0); NVIC_SetPriority(EINT1_IRQn,1); NVIC_SetPriority(EINT2_IRQn,2); NVIC_SetPriority(EINT3_IRQn,3); NVIC_SetPriority(TIMER0_IRQn,4); NVIC_SetPriority(TIMER1_IRQn,5); NVIC_SetPriority(TIMER2_IRQn,6); NVIC_SetPriority(TIMER3_IRQn,7);*/ encoder.setup(2000,0); pc.baud(460800); while(1) { encoder.calculate(); encoder2.calculate(); pc.printf("%d, %d\r\n", int(encoder.getData(COUNT)), int(encoder2.getData(COUNT))); wait_ms(10); //pc.printf("COUNT_%f\tROTATION_%f\tRPM_%frpm\tDISTANCE_%fmm\tANGLE_%f\tPOSITION_%f\r\n",encoder.getData(COUNT),encoder.getData(ROTATION),encoder.getData(RPM),encoder.getData(DISTANCE),encoder.getData(ANGLE),encoder.getData(POSITION)); } }