statemachine
Dependencies: mbed QEI HIDScope biquadFilter MODSERIAL FastPWM
main.cpp
- Committer:
- ehopman
- Date:
- 2019-10-04
- Revision:
- 21:041cc8aaac31
- Parent:
- 20:184839c241a7
File content as of revision 21:041cc8aaac31:
#include "mbed.h" #include "MODSERIAL.h" #include "FastPWM.h" #include "QEI.h" Serial pc(USBTX,USBRX); // functies aan PINs toevoegen FastPWM led(PTA1); FastPWM motor(D5); AnalogIn pot(PTB2); AnalogIn pot(PTB2); InterruptIn button(PTB3); // timer opzetten = ticker Ticker ticker; // opzetten van hoekbepaling QEI encoder (D13,D12,NC,32,X4_ENCODING); // aparte functies // functie hoekbepaling void hoek_bepaling() { encoder.getPulses(); } //functie motor aansturen met pot void motor_running() { motor.write(pot); led.write(pot); } // functie print output void print_output() { pc.printf("motor speed is (%f)\r\n",pot.read()); pc.printf("pulse is (%i)\r\n",encoder.getPulses()); } // functie change direction void change_direction() { void main_loop() { hoek_bepaling(); motor_running(); } void print_loop() { print_output(); } enum (start_wait, move) // main functie !! int main() { ticker.attach(&main_loop, 0.001f, &print_loop, 1f); while(true){}; }