br g5
Dependencies: mbed QEI HIDScope biquadFilter MODSERIAL FastPWM
Diff: main.cpp
- Revision:
- 15:49f750d895d7
- Parent:
- 14:4342436f9f4f
diff -r 4342436f9f4f -r 49f750d895d7 main.cpp --- a/main.cpp Mon Sep 23 07:54:49 2019 +0000 +++ b/main.cpp Mon Sep 23 08:27:53 2019 +0000 @@ -1,8 +1,8 @@ #include "mbed.h" -#include "MODSERIAL.h"; -#include "FastPWM.h" ; -#include "QEI.h" ; -#include "Motor.h" ; +#include "MODSERIAL.h" +#include "FastPWM.h" +#include "QEI.h" +//#include "Motor.h" Serial pc(USBTX,USBRX); @@ -11,15 +11,16 @@ FastPWM motor(D5); FastPWM led(PTA1); +DigitalOut direction(D4); int pulses = 131; QEI wheel (D13,D12,NC,pulses); -int pin = 1; +int richting; void flip() { - pin=!pin; + richting=!richting; } @@ -29,19 +30,25 @@ button.rise(&flip); while(true) { - if (pin == 1) + if (richting == 1) { + wait(0.05); printf("now forward"); led.write(pot); motor.write(pot); + wait(0.05); + direction.write(richting); //printf("motor speeed is (%f)\n\r",pot.read()); //printf("pulse number is (%i)\n\r",wheel.getPulses()); } else { + wait(0.05); printf("now reversing"); led.write(1-pot); motor.write(pot); + wait(0.05); + direction.write(richting); //printf("motor speeed is (%f)\n\r",pot.read()); //printf("pulse number is (%i)\n\r",wheel.getPulses()); }