Opzetje
Dependencies: mbed QEI HIDScope biquadFilter MODSERIAL FastPWM
Diff: main.cpp
- Revision:
- 7:2f612f32711a
- Parent:
- 6:3930811edddf
diff -r 3930811edddf -r 2f612f32711a main.cpp --- a/main.cpp Mon Sep 23 13:56:11 2019 +0000 +++ b/main.cpp Tue Oct 01 14:45:37 2019 +0000 @@ -1,27 +1,56 @@ #include "mbed.h" #include "MODSERIAL.h" -#include "FastPWM.h" +#include "FastPWM.h" +#include "QEI.h" Serial pc(USBTX,USBRX); -InterruptIn button1(PTC2); -InterruptIn button2(PTC3); -InterruptIn button3(PTA4); -InterruptIn button4(PTC6); +// functies aan PINs toevoegen +FastPWM led(PTA1); +FastPWM motor(D5); AnalogIn pot(PTB2); +InterruptIn button(PTB3); -FastPWM motor(D5); +// timer opzetten = ticker +Ticker ticker_a; + +// opzetten van hoekbepaling +int pulses = 4200; +QEI encoder (D13,D12,NC,pulses); -Ticker ticker; +// aparte functies +// functie hoekbepaling +void hoek_bepaling() +{ + encoder.getPulses(); +} +//functie motor aansturen met pot void motor_speed() { motor.write(pot); } -int main() +// functie print output +void print_output() { - ticker.attach(&motor_speed, 0.001f); - while(true){}; -} \ No newline at end of file + pc.printf("pot value is (%f)\r\n",pot.read()); + //pc.printf("pulse is (%i)\r\n",encoder.getPulses()); + +} + +void main_loop() +{ print_output(); + + //if(button.read() == 0){ + //hoek_bepaling(); + motor_speed(); + +} + +int main() +{ + ticker_a.attach(&main_loop, 0.001f); + while(true){}; +} \ No newline at end of file