Opzetje
Dependencies: mbed QEI HIDScope biquadFilter MODSERIAL FastPWM
main.cpp
- Committer:
- s1868365
- Date:
- 2019-10-04
- Revision:
- 9:19682cb1d8ee
- Parent:
- 7:2f612f32711a
File content as of revision 9:19682cb1d8ee:
#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); InterruptIn button(PTB3); // timer opzetten = ticker Ticker ticker_a; // opzetten van hoekbepaling int pulses = 4200; QEI encoder (D13,D12,NC,pulses); // aparte functies // functie hoekbepaling void hoek_bepaling() { encoder.getPulses(); } //functie motor aansturen met pot void motor_speed() { motor.write(pot); } // functie print output void print_output() { 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){}; }