![](/media/cache/group/9e3cc099b3b04bca937a1cca1da81b19.jpg.50x50_q85.jpg)
Poah als je je encoder in je motor wil aflezen en de beweging van je motor wilt aanpassen is dit programma echt voor jou!
Dependencies: mbed QEI HIDScope biquadFilter MODSERIAL FastPWM
Diff: main.cpp
- Revision:
- 0:1843eec2b552
- Child:
- 1:68f74b2ceb7d
diff -r 000000000000 -r 1843eec2b552 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Sep 20 12:38:05 2019 +0000 @@ -0,0 +1,33 @@ +#include "mbed.h" +//#include "HIDScope.h" +#include "QEI.h" +#include "MODSERIAL.h" +//#include "BiQuad.h" +//#include "FastPWM.h" + +DigitalOut ledr(LED_RED); +DigitalOut ledg(LED_GREEN); +DigitalOut ledb(LED_BLUE); +PwmOut led1(D10); +DigitalIn button1(D2); +AnalogIn potmeter(A1); +DigitalIn sw(SW2); +MODSERIAL pc(USBTX, USBRX); +DigitalIn encA(D13); +DigitalIn encB(D12); +QEI encoder(D13,D12,NC,64,QEI::X4_ENCODING); + +int counts; +float degree; +float factor= 5.625; +int main() +{ + pc.baud(115200); + pc.printf("\r\nStarting...\r\n\r\n"); + while (true) { + counts= encoder.getPulses(); + degree= counts*factor; + pc.printf("%f \r\n", degree); + wait(0.5); + } +}